Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
1586 Visualizzazioni

Hi everyone.

i am trying to tweak an addon i purchased last year for my company. (mrp tags)
i have done 90% tweaks and its coming along very nicely. one point which i am unable to grasp / solve is filter..
to me it seems, i am pretty close, but unable to grasp domain filter completely.
BTW, using odoo13.



on pointer 3 ( trying to solve subcontract) part, where each rec name has equivalent inventory product (type=service) with 2 or 3 vendors (contacts in it) as supplier of service. >> 

my model looks like 
------------------------------------------

-------mrp_custom_checklist.py---------

------------------------------------------
class MrpCustomChecklist(models.Model):

​_inherit = 'mrp.production'

​ partner_id = fields.Many2one('res.partner', string='Partner')


​@api.model

​def get_service_vendors(self):

​service_products = self.env['product.product'].search([('type', '=', 'service')])

​vendor_ids = service_products.mapped('seller_ids.name.id')

​vendor_records = self.env['res.partner'].browse(vendor_ids)

​vendor_names = vendor_records.mapped('name')

​return vendor_names

​ @api.model

​ def get_named_service_vendors(self,product_name):

​ service_product = self.env['product.product'].search([('type', '=', 'service'), ('name', 'ilike', product_name)], limit=1)

​ vendor_ids = service_product.mapped('seller_ids.name.id')

​ vendor_records = self.env['res.partner'].browse(vendor_ids)

​ vendor_names = vendor_records.mapped('name')

​ return vendor_names


and XML looks like 
------------------------------------------

-------mrp_custom_checklist.xml---------

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

" rel="ugc">ir.ui.view">

mrp.custom.checklist.form

​  

===========

PROBLEM

==========

Field 'get_service_vendors' used in attributes must be present in view but is missing:

  • 'get_service_vendors' in domain="[('id', 'in', get_service_vendors())]"

Error context: View mrp.custom.checklist.form

 
any ideas.??

Avatar
Abbandona
Risposta migliore

You cannot use a function in the domain inside the view file, because it must be present in the view.

Please try to use a compute field with the needed type and use it in the domain.

Hope this helps

Avatar
Abbandona
Autore

for reference, if someone stuck in same place ( in future )

@api.depends('mode')
def _compute_partner_id(self):
for record in self:

service_products = self.env['product.product'].search([('type', '=', 'service')])
print ("TOTAL SERVICES:",len(service_products))
vendor_ids = service_products.mapped('seller_ids.name.id')[:1]
print ("TOTAL VENDORS (INTENTIONAL LIMIT):",len(vendor_ids))
print ("VENDOR IDS:",vendor_ids)
vendor = self.env['res.partner'].browse(vendor_ids)
print ("VENDOR ID:",vendor)

if vendor:
print ("VENDOR NAME:",vendor.name)
record.partner_id = vendor.id
else:
record.partner_id = False

Post correlati Risposte Visualizzazioni Attività
1
set 23
2363
1
nov 22
3481
1
mag 25
1025
1
mar 25
1246
1
feb 25
1635