If a customer has a few of the same products we offer but with a different part number can the respective customer part number be included on the sale order acknowledgement report. I'm not sure if a onetomany field should be added to the product template or the customer and how the report can be modified to know to include the customer's part number if the respective product is a sale order line. I'm fairly new working with Odoo 16 and not too savvy in Python, but use studio customizations.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- 회계
- 재고 관리
- PoS
- Project
- MRP
you can add a One2many field in the customer model to associate each product with its corresponding part number for that customer. Here's an example of how you can achieve this:
from odoo import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
customer_part_numbers = fields.One2many(
comodel_name='customer.part.number',
inverse_name='customer_id',
string='Customer Part Numbers',
)
from odoo import fields, models
class CustomerPartNumber(models.Model):
_name = 'customer.part.number'
_description = 'Customer Part Number'
customer_id = fields.Many2one(
comodel_name='res.partner',
string='Customer',
required=True,
)
product_id = fields.Many2one(
comodel_name='product.template',
string='Product',
required=True,
)
part_number = fields.Char(string='Part Number')
tbody>
t t-foreach="o.order_line" t-as="line">
tr>
td>
td>
td>
!-- Add the customer part number column -->
td>
span t-esc="get_customer_part_number(o.partner_id.id, line.product_id.id)"/>
td>
/tr>
/t>
/tbody>
In the above snippet, the get_customer_part_number function is used to retrieve the customer's part number for the given customer and product. You'll need to define this function in the report's Python code to fetch the corresponding part number from the customer.part.number model.
Thank you! this worked and I'm all set.