Browse Source

[IMP] - permit contract selection without contract_template_id

pull/208/head
sbejaoui 6 years ago
committed by Thomas Binsfeld
parent
commit
50aeb77ec0
  1. 7
      product_contract/models/sale_order_line.py
  2. 7
      product_contract/views/sale_order.xml

7
product_contract/models/sale_order_line.py

@ -181,7 +181,9 @@ class SaleOrderLine(models.Model):
predecessor_contract_line = rec.contract_line_id predecessor_contract_line = rec.contract_line_id
if predecessor_contract_line: if predecessor_contract_line:
new_contract_line = contract_line_env.create( new_contract_line = contract_line_env.create(
rec._prepare_contract_line_values(contract, predecessor_contract_line.id)
rec._prepare_contract_line_values(
contract, predecessor_contract_line.id
)
) )
predecessor_contract_line.successor_contract_line_id = ( predecessor_contract_line.successor_contract_line_id = (
new_contract_line new_contract_line
@ -210,7 +212,8 @@ class SaleOrderLine(models.Model):
for rec in self: for rec in self:
if rec.contract_id: if rec.contract_id:
if ( if (
rec.contract_template_id
rec.contract_id.contract_template_id
and rec.contract_template_id
!= rec.contract_id.contract_template_id != rec.contract_id.contract_template_id
): ):
raise ValidationError( raise ValidationError(

7
product_contract/views/sale_order.xml

@ -29,8 +29,13 @@
position="after"> position="after">
<field name="contract_template_id" invisible="1"/> <field name="contract_template_id" invisible="1"/>
<field name="contract_id" <field name="contract_id"
options='{"no_create": True}'
attrs="{'invisible': [('is_contract', '=', False)]}" attrs="{'invisible': [('is_contract', '=', False)]}"
domain="[('partner_id','=',parent.partner_id),('contract_template_id','=',contract_template_id)]"/>
domain="['|',('contract_template_id','=',contract_template_id),
('contract_template_id','=',False),
('partner_id','=',parent.partner_id),
('recurring_invoices','=',True),
]"/>
<field name="contract_line_id" <field name="contract_line_id"
attrs="{'invisible': [('is_contract', '=', False)]}" attrs="{'invisible': [('is_contract', '=', False)]}"
domain="[('contract_id','=',contract_id)]"/> domain="[('contract_id','=',contract_id)]"/>

Loading…
Cancel
Save