Compare commits
5 Commits
14-fix-mig
...
12_sale_pi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfb704cd07 | ||
|
|
982c781edf | ||
|
|
d2f3227f53 | ||
|
|
2bddfa49f6 | ||
|
|
30334e617d |
@@ -2,7 +2,7 @@
|
|||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import models, fields
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
|
||||||
class SaleOrder(models.Model):
|
class SaleOrder(models.Model):
|
||||||
@@ -10,3 +10,41 @@ class SaleOrder(models.Model):
|
|||||||
|
|
||||||
warehouse_id = fields.Many2one(track_visibility='onchange')
|
warehouse_id = fields.Many2one(track_visibility='onchange')
|
||||||
incoterm = fields.Many2one(track_visibility='onchange')
|
incoterm = fields.Many2one(track_visibility='onchange')
|
||||||
|
picking_status = fields.Selection([
|
||||||
|
('delivered', 'Fully Delivered'),
|
||||||
|
('partially_delivered', 'Partially Delivered'),
|
||||||
|
('to_deliver', 'To Deliver'),
|
||||||
|
('cancel', 'Delivery Cancelled'),
|
||||||
|
('no', 'Nothing to Deliver')
|
||||||
|
], string='Picking Status', compute='_compute_picking_status',
|
||||||
|
store=True, readonly=True)
|
||||||
|
|
||||||
|
@api.depends('state', 'picking_ids.state')
|
||||||
|
def _compute_picking_status(self):
|
||||||
|
"""
|
||||||
|
Compute the picking status for the SO. Possible statuses:
|
||||||
|
- no: if the SO is not in status 'sale' nor 'done', we consider that
|
||||||
|
there is nothing to deliver. This is also the default value if the
|
||||||
|
conditions of no other status is met.
|
||||||
|
- cancel: all pickings are cancelled
|
||||||
|
- delivered: if all pickings are done or cancel.
|
||||||
|
- partially_delivered: If at least one picking is done.
|
||||||
|
- to_deliver: if all pickings are in confirmed, assigned, waiting or
|
||||||
|
cancel state.
|
||||||
|
"""
|
||||||
|
for order in self:
|
||||||
|
picking_status = 'no'
|
||||||
|
if order.state in ('sale', 'done') and order.picking_ids:
|
||||||
|
pstates = [
|
||||||
|
picking.state for picking in order.picking_ids]
|
||||||
|
if all([state == 'cancel' for state in pstates]):
|
||||||
|
picking_status = 'cancel'
|
||||||
|
elif all([state in ('done', 'cancel') for state in pstates]):
|
||||||
|
picking_status = 'delivered'
|
||||||
|
elif any([state == 'done' for state in pstates]):
|
||||||
|
picking_status = 'partially_delivered'
|
||||||
|
elif all([
|
||||||
|
state in ('confirmed', 'assigned', 'waiting', 'cancel')
|
||||||
|
for state in pstates]):
|
||||||
|
picking_status = 'to_deliver'
|
||||||
|
order.picking_status = picking_status
|
||||||
|
|||||||
@@ -30,4 +30,41 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="view_order_form" model="ir.ui.view">
|
||||||
|
<field name="name">sale_stock_usability.order.form</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="pricelist_id" position="after">
|
||||||
|
<field name="picking_status"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_order_tree" model="ir.ui.view">
|
||||||
|
<field name="name">sale_stock_usability.order.tree</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="inherit_id" ref="sale.view_order_tree"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="invoice_status" position="after">
|
||||||
|
<field name="picking_status"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_sales_order_filter" model="ir.ui.view">
|
||||||
|
<field name="name">sale_stock_usability.order.search</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="inherit_id" ref="sale.view_sales_order_filter"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<filter name="my_sale_orders_filter" position="after">
|
||||||
|
<separator/>
|
||||||
|
<filter string="Not Fully Delivered" name="not_fully_delivered"
|
||||||
|
domain="[('picking_status', 'in', ('to_deliver', 'partially_delivered'))]"/>
|
||||||
|
<filter string="Fully Delivered" name="fully_delivered"
|
||||||
|
domain="[('picking_status', '=', 'delivered')]"/>
|
||||||
|
</filter>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
Reference in New Issue
Block a user