I want to create clearance for a contract with some items with 3 attributes of every item I have 4 models:
Contract
Clearance
- item
- Clearance_item_rel
When I'm in the custom view of clearance model I select a contract
from Many2one
relation field
then try to create a Clearance_item_rel
record in the
Clearance_item_rel
model.
When I click to create a Clearance_item_rel
record it opens the
custom view in a new window
I want to use the selected contract id in the first view to fill the contract_id
field in Clearance_item_rel
automatically as the user has just selected it in the first view
P.S:
clearance_id
is created automatically as I create theClearance_item_rel
record from clearance custom view Butcontract_id
doesn't do and this's my problem
Contract:
class Contract(models.Model):
_name = 'clearance.contract'
clearances = fields.One2many('clearance.clearance_item_rel',
'contract_id')
clearance:
class Clearance(models.Model):
_name = 'clearance.clearance'
contract = fields.Many2one('clearance.contract','Contract')
items = fields.One2many('clearance.clearance_item_rel',clearance_id')
Clearance_item_rel:
class Clearance_item_rel(models.Model):
_name = 'clearance.clearance_item_rel'
contract_id = fields.Many2one('clearance.contract', 'Contract', ondelete='cascade')
clearance_id = fields.Many2one('clearance.clearance', 'Clearance', ondelete='cascade')
item_id = fields.Many2one('clearance.contract_item_rel', 'Item', ondelete='cascade')
previous_quantity = fields.Integer()
used_quantity = fields.Integer()
total_price = fields.Integer()