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

Hi

I have a first model  with a many2many field map_ids pointing to second model. First i take a particular object with the first model, and then I want to search in the second model for another record with different filter.

    def _get_mapped_line_account(self):
        for res in self:
            map = self.env['acg.map'].search([('id', '=', res.product_id.product_tmpl_id.income_acgmap_id.id)], limit=1)
            cg = self.env['res.country.group'].search([('country_ids', 'in', res.invoice_id.partner_shipping_id.country_id.id)], limit=1).id
            cg_map = map.map_ids.search([('country_group_id', '=', cg)])
            print(cg_map)

But when I do it, it does not take the previous search, it's just show all objects from the second model with this filter applied . Is this the right way to search a particular record with a different filter(country_group_id) in many2many relation.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ม.ค. 19
8446
1
ธ.ค. 15
4410
1
มี.ค. 15
6399
0
มี.ค. 15
3461
1
ก.ค. 25
419