Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
3 Vastaukset
2648 Näkymät

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.


Avatar
Hylkää
Paras vastaus

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

Avatar
Hylkää

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

Paras vastaus

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

Avatar
Hylkää