suppose I have 10 samsung s4 in my stock with 10 different serial numnbers while generating a sale order i select samsung s4 in products there is one2many line in sale.order.line where i need to select available serial numbers(m2o field) of the particular phone now my problem is how to use domain so that selected serial numbers are not shown in list for selling eg : if i have selected serial no 1,2,3 under three lines of sale order line then in line 4 ..selected serial number should not be shown
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
Hi,
Consider the following example.
inherit='sale.order.line'
@api.onchange('product_id')
def onchange_product_id(self):
if self.product_id:
domain = [
('product_id', '=', self.product_id.id),
('id', 'not in', self.order_id.order_line.mapped('product_serial_number_id').ids)
]
return {'domain': {'product_serial_number_id': domain}}
else:
return{}
This onchange method sets the domain filter on the product_serial_number_id field based on the selected Samsung S4 product and the serial numbers that have already been selected in other sale order lines. The order_id field is used to access the parent sale.order record, and its order_line field is used to access the existing sale order line records.
Regards
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrirePublications associées | Réponses | Vues | Activité | |
---|---|---|---|---|
|
7
avr. 23
|
18505 | ||
|
0
sept. 20
|
2235 | ||
|
1
sept. 19
|
3484 | ||
|
0
avr. 16
|
2653 | ||
One2many onchange in ODOO
Résolu
|
|
3
mars 16
|
13266 |