跳至內容
選單
此問題已被標幟
3 回覆
2633 瀏覽次數

Hello,


On an order/invoice, i select a customer and at the shipping address it displays all of the contacts on record. I want to display only the contacts and addresses of the customer I've selected.


Thank you.


頭像
捨棄
最佳答案

Hi,
You can achieve this by adding domain for the contact field of sale order.If you want to set whether a contact need to be shown in the shipping address in the contact form, add a boolean field inside contact form and show only those contact for which this boolean is enabled.For example if the boolean field is

test_boolean = fields.Boolean()

Then the domain will be [('test_boolean', '=', True)]

Regards

頭像
捨棄

This will show all the delivery addresses for all the companies. i have tried to filter it out with ["parent_id","=","partner_id"] but then doesnt populate anything

最佳答案

Inherit the field and add ('parent_id','=',partner_id) to the domain:

class SaleOrder(models.Model):
_inherit = 'sale.order'

partner_shipping_id = fields.Many2one(
comodel_name='res.partner',
string="Delivery Address",
compute='_compute_partner_shipping_id',
store=True, readonly=False, required=True, precompute=True,
states=LOCKED_FIELD_STATES,
domain="['|','&',('company_id', '=', False), ('company_id', '=', company_id), ('parent_id','=',partner_id)]")

頭像
捨棄