Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
2615 Widoki

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.


Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć

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

Najlepsza odpowiedź

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)]")

Awatar
Odrzuć