Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
3838 Widoki

I want to add a wizard with Many2many field of 'stock.production.lot' displaying only the records with doubled Lot/Serial Number i did the function that get the filtred records 

--------------------

class DoublingNumber(models.TransientModel):
_name = 'doubling.number'


double_number_id =fields.Many2many('stock.production.lot' ,string="Numéros en doublant" )

@api.multi
def _default_double_number(self):
    double_record = []
    records =self.env['stock.production.lot'].search([])
    for record in records :
        for record2 in records :
            if record.name == record2.name and record.product_id != record2.product_id :
                double_record.append(record2)
                break
    return double_record

--------------

Now how to display it ??!

Awatar
Odrzuć
Autor Najlepsza odpowiedź

For anyone needing the answer here it is : 

class DoublingNumber(models.TransientModel):
_name = 'doubling.number'

@api.model
def _default_double_number(self):
log.warning("Hola")
double_record = self.env['stock.production.lot']
records =self.env['stock.production.lot'].search([])
for record in records :
for record2 in records :
if record.name == record2.name and record.product_id != record2.product_id :

double_record += record2

break
return double_record

double_number_id =fields.Many2many('stock.production.lot' ,string="Numéros en doublant", default = _default_double_number)

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
4
cze 22
14932
0
mar 21
2263
0
maj 18
3264
1
lis 17
5028
1
sty 16
7296