Community mailing list archives

community@mail.odoo.com

Re: NEW API-BROWSING ANOTHER MODEL

by
mudoko
- 02/27/2016 05:21:41
This iswhat am getting when i run it

AttributeError: 'NewId' object has no attribute 'id'


Laballieds,

Nairobi:gate 256, Nairobi.

P.O.Box - 45855 -00100, Nairobi.

Tel:+254 721449067

Email petypi@gmail.com

Mobile: +254 721449067

Website www.softlinkoptions.com


On Sat, Feb 27, 2016 at 12:24 PM, Peter Mudoko <petypi@gmail.com> wrote:
 a small change on bom_obj = rec.env['mrp.bom.line'].search([('bom_id', '=', id)]), IS
ANY HELP KINDLY OF HOW TO ACCOMPLISH THIS, AM LEARNING ODOO ALOT


Systems developer

Laballieds,

Nairobi:gate 256, Nairobi.

P.O.Box - 45855 -00100, Nairobi.

Tel:+254 721449067

Email petypi@gmail.com

Mobile: +254 721449067

Website www.softlinkoptions.com


On Sat, Feb 27, 2016 at 12:19 PM, Peter Mudoko <petypi@gmail.com> wrote:
Hi guys, am trying to use an an @api onchange event to alter quanties of components in bill of material   form , The essence is everytime we have production required capacity that is entered manuallyon the bom list view that should trigger this update, This is the script:

@api.onchange('quantity','batch')
    def onchangeQuantity(self):
   for rec in self:
       rec.batch=rec.quantity/rec.product_qty
self.bom_Calc(rec.batch)
     @api.model
def bom_Calc(self,value):
'''update the component bom lines'''
   for rec in self:
id=rec.id
bom_obj = rec.env['mrp.bom.line'].search([('id', '=', id)])
bom_obj.quantityRequired=bom_obj.quantityRequired*value
bom_obj.shortage=bom_obj.quantityRequired-bom_obj.qoh
I need to see the changes when bom is exploded


Systems developer

Laballieds,

Nairobi:gate 256, Nairobi.

P.O.Box - 45855 -00100, Nairobi.

Tel:+254 721449067

Email petypi@gmail.com

Mobile: +254 721449067

Website www.softlinkoptions.com