[IMP] sale, delivery: improvements in workflows, buttons and SO form view. (delivery) Replaced the wizard to add delivery cost by a function on the SO directly
bzr revid: qdp-launchpad@openerp.com-20120525102643-60o5761u2mzrooa9
This commit is contained in:
parent
9a99ce2577
commit
f4cfeae2c1
|
@ -21,7 +21,6 @@
|
|||
|
||||
import delivery
|
||||
import partner
|
||||
import wizard
|
||||
import report
|
||||
import sale
|
||||
import stock
|
||||
|
|
|
@ -37,7 +37,6 @@ When creating invoices from picking, OpenERP is able to add and compute the ship
|
|||
'init_xml': ['delivery_data.xml'],
|
||||
'update_xml': [
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/delivery_sale_order_view.xml',
|
||||
'delivery_report.xml',
|
||||
'delivery_view.xml',
|
||||
'partner_view.xml'
|
||||
|
|
|
@ -161,19 +161,6 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_order_withcarrier_form" model="ir.ui.view">
|
||||
<field name="name">delivery.sale.order_withcarrier.form.view</field>
|
||||
<field name="type">form</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<group name="logistics" position="inside">
|
||||
<field name="id" invisible="True"/>
|
||||
<field name="carrier_id" context="{'order_id':active_id or False}"/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_withcarrier_out_form" model="ir.ui.view">
|
||||
<field name="name">delivery.stock.picking_withcarrier.out.form.view</field>
|
||||
<field name="type">form</field>
|
||||
|
@ -258,14 +245,18 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="edit_project_multicompany">
|
||||
<field name="name">sale.order.multicompany</field>
|
||||
<record id="view_order_withcarrier_form" model="ir.ui.view">
|
||||
<field name="name">delivery.sale.order_withcarrier.form.view</field>
|
||||
<field name="type">form</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='order_confirm']" position="after">
|
||||
<button name="%(action_delivery_cost)d" states="draft" string="Delivery Costs" type="action" icon="gtk-add" context="{'order_id':active_id}"/>
|
||||
</xpath>
|
||||
<xpath expr="//group[@name='bellow_the_lines_hook']" position="inside">
|
||||
<separator string="Delivery Costs" colspan="4"/>
|
||||
<field name="carrier_id" context="{'order_id':active_id or False}" colspan="2"/>
|
||||
<button name="delivery_set" states="draft" string="Add Now on the Sale Order" type="object" icon="gtk-add" colspan="2"/>
|
||||
<label string="if you don't click on 'Add Now', the delivery cost won't be added on the Sale Order, but will be added on the Delivery Order only" colspan="4"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
from osv import fields,osv
|
||||
|
||||
import time
|
||||
|
||||
# Overloaded sale_order to manage carriers :
|
||||
class sale_order(osv.osv):
|
||||
|
@ -41,6 +41,39 @@ class sale_order(osv.osv):
|
|||
result.update(carrier_id=order.carrier_id.id)
|
||||
return result
|
||||
|
||||
def delivery_set(self, cr, uid, ids, context=None):
|
||||
order_obj = self.pool.get('sale.order')
|
||||
line_obj = self.pool.get('sale.order.line')
|
||||
grid_obj = self.pool.get('delivery.grid')
|
||||
carrier_obj = self.pool.get('delivery.carrier')
|
||||
acc_fp_obj = self.pool.get('account.fiscal.position')
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
grid_id = carrier_obj.grid_get(cr, uid, [order.carrier_id.id], order.partner_shipping_id.id)
|
||||
if not grid_id:
|
||||
raise osv.except_osv(_('No grid available !'), _('No grid matching for this carrier !'))
|
||||
|
||||
if not order.state in ('draft'):
|
||||
raise osv.except_osv(_('Order not in draft state !'), _('The order state have to be draft to add delivery lines.'))
|
||||
|
||||
grid = grid_obj.browse(cr, uid, grid_id, context=context)
|
||||
|
||||
taxes = grid.carrier_id.product_id.taxes_id
|
||||
fpos = order.fiscal_position or False
|
||||
taxes_ids = acc_fp_obj.map_tax(cr, uid, fpos, taxes)
|
||||
#create the sale order line
|
||||
line_obj.create(cr, uid, {
|
||||
'order_id': order.id,
|
||||
'name': grid.carrier_id.name,
|
||||
'product_uom_qty': 1,
|
||||
'product_uom': grid.carrier_id.product_id.uom_id.id,
|
||||
'product_id': grid.carrier_id.product_id.id,
|
||||
'price_unit': grid_obj.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
|
||||
'tax_id': [(6,0,taxes_ids)],
|
||||
'type': 'make_to_stock'
|
||||
})
|
||||
#remove the value of the carrier_id field on the sale order
|
||||
return self.write(cr, uid, ids, {'carrier_id': False}, context=context)
|
||||
#return {'type': 'ir.actions.act_window_close'} action reload?
|
||||
|
||||
sale_order()
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import delivery_sale_order
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
from tools.translate import _
|
||||
|
||||
from osv import osv, fields
|
||||
|
||||
class make_delivery(osv.osv_memory):
|
||||
_name = "delivery.sale.order"
|
||||
_description = 'Make Delievery'
|
||||
|
||||
_columns = {
|
||||
'carrier_id': fields.many2one('delivery.carrier','Delivery Method', required=True),
|
||||
}
|
||||
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
res = super(make_delivery, self).default_get(cr, uid, fields, context=context)
|
||||
order_obj = self.pool.get('sale.order')
|
||||
for order in order_obj.browse(cr, uid, context.get('active_ids', []), context=context):
|
||||
carrier = order.carrier_id.id
|
||||
if not carrier:
|
||||
carrier = order.partner_id.property_delivery_carrier.id
|
||||
res.update({'carrier_id': carrier})
|
||||
|
||||
return res
|
||||
|
||||
def view_init(self, cr , uid , fields, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
order_obj = self.pool.get('sale.order')
|
||||
for order in order_obj.browse(cr, uid, context.get('active_ids', []), context=context):
|
||||
if not order.state in ('draft'):
|
||||
raise osv.except_osv(_('Order not in draft state !'), _('The order state have to be draft to add delivery lines.'))
|
||||
pass
|
||||
|
||||
def delivery_set(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
rec_ids = context and context.get('active_ids',[])
|
||||
order_obj = self.pool.get('sale.order')
|
||||
line_obj = self.pool.get('sale.order.line')
|
||||
grid_obj = self.pool.get('delivery.grid')
|
||||
carrier_obj = self.pool.get('delivery.carrier')
|
||||
acc_fp_obj = self.pool.get('account.fiscal.position')
|
||||
order_objs = order_obj.browse(cr, uid, rec_ids, context=context)
|
||||
for datas in self.browse(cr, uid, ids, context=context):
|
||||
for order in order_objs:
|
||||
grid_id = carrier_obj.grid_get(cr, uid, [datas.carrier_id.id],order.partner_shipping_id.id)
|
||||
if not grid_id:
|
||||
raise osv.except_osv(_('No grid available !'), _('No grid matching for this carrier !'))
|
||||
|
||||
if not order.state in ('draft'):
|
||||
raise osv.except_osv(_('Order not in draft state !'), _('The order state have to be draft to add delivery lines.'))
|
||||
|
||||
grid = grid_obj.browse(cr, uid, grid_id, context=context)
|
||||
|
||||
taxes = grid.carrier_id.product_id.taxes_id
|
||||
fpos = order.fiscal_position or False
|
||||
taxes_ids = acc_fp_obj.map_tax(cr, uid, fpos, taxes)
|
||||
line_obj.create(cr, uid, {
|
||||
'order_id': order.id,
|
||||
'name': grid.carrier_id.name,
|
||||
'product_uom_qty': 1,
|
||||
'product_uom': grid.carrier_id.product_id.uom_id.id,
|
||||
'product_id': grid.carrier_id.product_id.id,
|
||||
'price_unit': grid_obj.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
|
||||
'tax_id': [(6,0,taxes_ids)],
|
||||
'type': 'make_to_stock'
|
||||
})
|
||||
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
make_delivery()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Delivery Sale Order -->
|
||||
|
||||
<record id="view_make_delivery_wizard" model="ir.ui.view">
|
||||
<field name="name">Delivery Costs</field>
|
||||
<field name="model">delivery.sale.order</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Create Deliveries">
|
||||
<separator colspan="4" string="Delivery Method" />
|
||||
<field name="carrier_id" widget="selection"/>
|
||||
<newline/>
|
||||
<separator colspan="4"/>
|
||||
<group col="2" colspan="4">
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="_Cancel" />
|
||||
<button name="delivery_set" string="_Apply"
|
||||
colspan="1" type="object" icon="gtk-apply" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_delivery_cost" model="ir.actions.act_window">
|
||||
<field name="name">Delivery Costs</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">delivery.sale.order</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_make_delivery_wizard"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -208,7 +208,7 @@ class sale_order(osv.osv):
|
|||
('cancel', 'Cancelled'),
|
||||
('waiting_date', 'Waiting Schedule'),
|
||||
('manual', 'Sale to Invoice'),
|
||||
('progress', 'Sale in Progress'),
|
||||
('progress', 'Sale Order'),
|
||||
('shipping_except', 'Shipping Exception'),
|
||||
('invoice_except', 'Invoice Exception'),
|
||||
('done', 'Done'),
|
||||
|
|
|
@ -102,19 +102,22 @@
|
|||
<button name="invoice_corrected" states="invoice_except" string="Ignore Exception"/>
|
||||
<button name="ship_recreate" states="shipping_except" string="Recreate Delivery Order"/>
|
||||
<button name="ship_corrected" states="shipping_except" string="Ignore Exception"/>
|
||||
<button name="action_quotation_sent" string="Send" type="object" states="draft,sent"/>
|
||||
<button name="action_quotation_sent" string="Send by Mail" type="object" states="draft" class="oe_form_button_hi"/>
|
||||
<button name="action_quotation_sent" string="Send by Mail" type="object" states="sent"/>
|
||||
<button name="manual_invoice" states="manual" string="Create Final Invoice" type="object"/>
|
||||
<button name="print_quotation" string="Print Quotation" type="object" states="draft,sent"/>
|
||||
<button name="order_confirm" states="draft,sent" string="Confirm Order" />
|
||||
<button name="print_quotation" string="Send by Post" type="object" states="draft" class="oe_form_button_hi"/>
|
||||
<button name="print_quotation" string="Send by Post" type="object" states="sent"/>
|
||||
<button name="order_confirm" states="draft" string="Confirm"/>
|
||||
<button name="order_confirm" states="sent" string="Confirm" class="oe_form_button_hi"/>
|
||||
<button name="action_view_invoice" string="Open Invoice" type="object"
|
||||
attrs="{'invisible': ['|','|',('state', '!=','progress'), ('invoiced', '=', True),('order_policy','=','picking')]}"/>
|
||||
<button name="action_view_delivery" string="Open Delivery Order" type="object"
|
||||
attrs="{'invisible': ['|','|','|',('picking_ids','=',False),('picking_ids','=',[]), ('state', 'not in', ('progress','manual')),('shipped','=',True)]}"/>
|
||||
<button name="%(action_view_sale_advance_payment_inv)d" string="Advance Invoice" type="action" states="draft,manual"/>
|
||||
<button name="cancel" states="draft,sent" string="Cancel Order"/>
|
||||
<button name="action_cancel" states="manual,progress" string="Cancel Order" type="object"/>
|
||||
<button name="ship_cancel" states="shipping_except" string="Cancel Order"/>
|
||||
<button name="invoice_cancel" states="invoice_except" string="Cancel Order"/>
|
||||
<button name="%(action_view_sale_advance_payment_inv)d" string="Advance Invoice" type="action" states="manual"/>
|
||||
<button name="cancel" states="draft,sent" string="Cancel"/>
|
||||
<button name="action_cancel" states="manual,progress" string="Cancel" type="object"/>
|
||||
<button name="ship_cancel" states="shipping_except" string="Cancel"/>
|
||||
<button name="invoice_cancel" states="invoice_except" string="Cancel"/>
|
||||
<div class="oe_right">
|
||||
<field name="state" nolabel="1" widget="statusbar" statusbar_visible="draft,sent,progress,invoiced,done" statusbar_colors='{"shipping_except":"red","invoice_except":"red","waiting_date":"blue"}'/>
|
||||
</div>
|
||||
|
@ -211,8 +214,9 @@
|
|||
<field name="price_subtotal" groups="base.group_sale_notes_subtotal"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
<div class="oe_form_subtotal_footer" colspan="4">
|
||||
<group colspan="2" col="4" name="bellow_the_lines_hook">
|
||||
</group>
|
||||
<div class="oe_form_subtotal_footer" colspan="2">
|
||||
<div>
|
||||
<field name="amount_untaxed" sum="Untaxed amount"/>
|
||||
</div>
|
||||
|
@ -284,7 +288,7 @@
|
|||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Sales Order">
|
||||
<filter icon="terp-document-new" string="Quotations" name="draft" domain="[('state','=','draft')]" help="Sales Order that haven't yet been confirmed"/>
|
||||
<filter icon="terp-document-new" string="Quotations" name="draft" domain="[('state','in',('draft','sent'))]" help="Sales Order that haven't yet been confirmed"/>
|
||||
<filter icon="terp-check" string="Sales" name="sales" domain="[('state','in',('manual','progress'))]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-dolar_ok!" string="To Invoice" domain="[('state','=','manual')]" help="Sales Order ready to be invoiced"/>
|
||||
|
|
|
@ -735,9 +735,9 @@ class stock_picking(osv.osv):
|
|||
""" Changes state of picking to available if all moves are confirmed.
|
||||
@return: True
|
||||
"""
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for pick in self.browse(cr, uid, ids):
|
||||
if pick.state == 'draft':
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_confirm', cr)
|
||||
move_ids = [x.id for x in pick.move_lines if x.state == 'confirmed']
|
||||
if not move_ids:
|
||||
|
|
Loading…
Reference in New Issue