Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
7297 มุมมอง

I'm on Odoo 9.0 and trying to inherit from stock.picking which has the Delivery module inheriting from it. The Delivery module adds a field named "carrier_id". I need to inherit and add a field named "carrier_service". When I override the create method in order to calculate a value for my new field I need to reference "carrier_id", but it's not in the dictionary of values passed to my create method resulting in a key error.

How can I do this? Code below;

class StockPicking(models.Model):
    _inherit = "stock.picking"
    carrier_service = fields.Char(string='Carrier Service')
    
    @api.model
    def create(self, values):
        carrier_mapping = (self.env["integration.carrier_mapping"].search([("delivery_method_id.id", "=", values['carrier_id'])])
        values['carrier_service']=carrier_mapping.service
        return super(StockPicking, self).create(values)
อวตาร
ละทิ้ง
ผู้เขียน

Tried adding the dependencies, but still didn't work. I've stopped working on this now as I found that the attribute that I'm interested in is actually done as an update after the initial insert. I'm able to reference the field correctly on update. Thanks for your suggestions.

คำตอบที่ดีที่สุด

In __openerp__.py you add (in depends section) the names of modules wchich are required for your module, in this case:

'depends': ['delivery'],

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Please try after updating the depends list with the module name 'stock'

eg: 'depends': ['stock'],

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
4
ก.พ. 25
2838
1
ส.ค. 24
2274
2
พ.ย. 24
3454
3
ต.ค. 23
14966
2
ก.พ. 23
2543