-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[14.0][ADD] sale_certificat_typology #281
base: 14.0
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## 14.0 #281 +/- ##
==========================================
+ Coverage 75.83% 80.54% +4.70%
==========================================
Files 83 130 +47
Lines 927 1444 +517
Branches 181 276 +95
==========================================
+ Hits 703 1163 +460
- Misses 194 240 +46
- Partials 30 41 +11 ☔ View full report in Codecov by Sentry. |
comodel_name="certificat.typology", string="Certificat typology", required=True | ||
) | ||
certificat = fields.Binary(string="Certificat", attachment=True) | ||
certificat_is_ok = fields.Boolean(string="Is valid ?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we can validate a certificate without uploading a certificate. Maybe hide the boolean in view or unallow to validate if no certificate ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kev-Roche , it's fixed.
On the sale order, we don't have information about which product(s) required a certificate. Maybe add the product name in the certificate page on each certificate line ? |
18d54f5
to
f24b1bd
Compare
@Kev-Roche , it's done. |
f24b1bd
to
f6af44a
Compare
@Kev-Roche , the changes made, are ok for you? |
@api.model_create_multi | ||
def create(self, vals_list): | ||
templates = super().create(vals_list) | ||
for template, vals in zip(templates, vals_list): | ||
if "required_certificat_ids" in vals: | ||
template.product_variant_ids.write( | ||
{"required_certificat_ids": vals["required_certificat_ids"]} | ||
) | ||
return templates | ||
|
||
def write(self, vals): | ||
res = super().write(vals) | ||
if "required_certificat_ids" in vals: | ||
self.product_variant_ids.write( | ||
{"required_certificat_ids": vals["required_certificat_ids"]} | ||
) | ||
return res | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_inherit = "product.product" | ||
|
||
required_certificat_ids = fields.Many2many( | ||
comodel_name="certificat.typology", | ||
string="Requested certificats", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am wrong, but the certificat should be required for all variant. So we do not need this code
@api.model_create_multi | |
def create(self, vals_list): | |
templates = super().create(vals_list) | |
for template, vals in zip(templates, vals_list): | |
if "required_certificat_ids" in vals: | |
template.product_variant_ids.write( | |
{"required_certificat_ids": vals["required_certificat_ids"]} | |
) | |
return templates | |
def write(self, vals): | |
res = super().write(vals) | |
if "required_certificat_ids" in vals: | |
self.product_variant_ids.write( | |
{"required_certificat_ids": vals["required_certificat_ids"]} | |
) | |
return res | |
class ProductProduct(models.Model): | |
_inherit = "product.product" | |
required_certificat_ids = fields.Many2many( | |
comodel_name="certificat.typology", | |
string="Requested certificats", | |
) |
class SaleOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
certificat_item_ids = fields.One2many( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@api.depends("order_line.product_id")
def _compute_certificat_item_ids(self):
for record in self:
required_certs = record.order_line.product_id.required_certificat_ids
items = record.certificat_item_ids.filtered(lamda s: s.typology_id in required_certs)
for cert in required_certs:
if cert not in items.typology_id:
items |= self.env["sale.order.certificat.item"].new({
"typology_id": cert.id,
})
record.certificat_item_ids = items
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebastienbeau , I made the suggested changes.
product_ids = fields.Many2many( | ||
comodel_name="product.product", | ||
string="Concerned products", | ||
compute="_compute_product_ids", | ||
readonly=False, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove, just add the related required_certificat_ids on sale.order.line with optional="hide"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebastienbeau , I made the suggested changes.
order_line_ids = fields.Many2many( | ||
comodel_name="sale.order.line", string="Linked order lines", required=True | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebastienbeau , I made the suggested changes.
cae5511
to
96ee09c
Compare
96ee09c
to
83a13ad
Compare
157f367
to
9cdfd90
Compare
No description provided.