[FIX] sale: add lines on a confirmed sale order.
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
This commit is contained in:
+1
-1
@@ -605,7 +605,7 @@ class SaleOrderLine(models.Model):
|
||||
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)
|
||||
|
||||
|
||||
@@ -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', '>', 0)]}"
|
||||
/>
|
||||
<field name="invoice_status" invisible="1"/>
|
||||
<field name="qty_to_invoice" invisible="1"/>
|
||||
@@ -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', '>', 0)]}"/>
|
||||
<label for="customer_lead"/>
|
||||
<div>
|
||||
<field name="customer_lead" class="oe_inline"/> days
|
||||
@@ -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', '>', 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"/>
|
||||
@@ -253,7 +254,8 @@
|
||||
groups="product.group_uom" options='{"no_open": True}'/>
|
||||
<field name="price_unit"
|
||||
attrs="{'readonly': [('qty_invoiced', '>', 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', '>', 0)]}"/>
|
||||
<field name="discount" groups="sale.group_discount_per_so_line"/>
|
||||
<field name="price_subtotal" widget="monetary"/>
|
||||
<field name="qty_delivered_updateable" invisible="1"/>
|
||||
|
||||
Reference in New Issue
Block a user