Skip to content

Commit

Permalink
[FIX] sale: add lines on a confirmed sale order.
Browse files Browse the repository at this point in the history
When using the editable list on the sale order form,
it was not possible to add a new line on a confirmed sale order,
while it should
(when `Allow to edit sales order` is chosen in the Sales settings).

The reason was that the fields `tax_id` and `product_id` were
set as readonly when the SO state was not draft.

When using the popup/dialog view, it worked by luck, because
the line `state`, which is a stored related field to the sale order state,
was not correctly computed, and was seen as `draft`, while it should
actually be `sale`, for a confirmed sale order.

We change the readonly condition of these fields,
which is now based on the fact wether or not
the line is already invoiced or not, which makes
more sense.

opw-651573
  • Loading branch information
beledouxdenis committed Oct 7, 2015
1 parent 4f9c9ad commit a5e737f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion addons/sale/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def write(self, values):
price_total = fields.Monetary(compute='_compute_amount', string='Total', readonly=True, store=True)

price_reduce = fields.Monetary(compute='_get_price_reduce', string='Price Reduce', readonly=True, store=True)
tax_id = fields.Many2many('account.tax', string='Taxes', readonly=True, states={'draft': [('readonly', False)]})
tax_id = fields.Many2many('account.tax', string='Taxes')

discount = fields.Float(string='Discount (%)', digits_compute=dp.get_precision('Discount'), default=0.0)

Expand Down
10 changes: 6 additions & 4 deletions addons/sale/sale_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<group>
<field name="product_id"
context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom, 'company_id': parent.company_id}"
attrs="{'readonly': [('state', 'in', ('sale','done', 'cancel'))]}"
attrs="{'readonly': [('qty_invoiced', '&gt;', 0)]}"
/>
<field name="invoice_status" invisible="1"/>
<field name="qty_to_invoice" invisible="1"/>
Expand Down Expand Up @@ -216,7 +216,8 @@
</div>
</group>
<group>
<field name="tax_id" widget="many2many_tags" domain="[('type_tax_use','=','sale'),('company_id','=',parent.company_id)]"/>
<field name="tax_id" widget="many2many_tags" domain="[('type_tax_use','=','sale'),('company_id','=',parent.company_id)]"
attrs="{'readonly': [('qty_invoiced', '&gt;', 0)]}"/>
<label for="customer_lead"/>
<div>
<field name="customer_lead" class="oe_inline"/> days
Expand All @@ -234,7 +235,7 @@
<tree string="Sales Order Lines" editable="bottom" decoration-info="invoice_status=='to invoice'">
<field name="sequence" widget="handle"/>
<field name="product_id"
attrs="{'readonly': [('state', 'in', ('sale','done', 'cancel'))]}"
attrs="{'readonly': [('qty_invoiced', '&gt;', 0)]}"
context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom, 'company_id': parent.company_id}"
/>
<field name="name"/>
Expand All @@ -253,7 +254,8 @@
groups="product.group_uom" options='{"no_open": True}'/>
<field name="price_unit"
attrs="{'readonly': [('qty_invoiced', '&gt;', 0)]}"/>
<field name="tax_id" widget="many2many_tags" domain="[('type_tax_use','=','sale'),('company_id','=',parent.company_id)]"/>
<field name="tax_id" widget="many2many_tags" domain="[('type_tax_use','=','sale'),('company_id','=',parent.company_id)]"
attrs="{'readonly': [('qty_invoiced', '&gt;', 0)]}"/>
<field name="discount" groups="sale.group_discount_per_so_line"/>
<field name="price_subtotal" widget="monetary"/>
<field name="qty_delivered_updateable" invisible="1"/>
Expand Down

0 comments on commit a5e737f

Please sign in to comment.