Skip to content
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

Open
wants to merge 3 commits into
base: 14.0
Choose a base branch
from

Conversation

chafique-delli
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Sep 20, 2023

Codecov Report

Attention: 10 lines in your changes are missing coverage. Please review.

Comparison is base (a69b8b3) 75.83% compared to head (96ee09c) 80.54%.
Report is 45 commits behind head on 14.0.

❗ Current head 96ee09c differs from pull request most recent head 9cdfd90. Consider uploading reports for the commit 9cdfd90 to get more accurate results

Files Patch % Lines
sale_certificat_typology/models/sale_order.py 76.19% 8 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

@chafique-delli
Copy link
Member Author

@Kev-Roche
@sebastienbeau

comodel_name="certificat.typology", string="Certificat typology", required=True
)
certificat = fields.Binary(string="Certificat", attachment=True)
certificat_is_ok = fields.Boolean(string="Is valid ?")
Copy link
Member

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 ?

Copy link
Member Author

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.

@Kev-Roche
Copy link
Member

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 ?

@chafique-delli chafique-delli force-pushed the 14.0-ADD-sale_certificat_typology branch 2 times, most recently from 18d54f5 to f24b1bd Compare October 4, 2023 09:44
@chafique-delli
Copy link
Member Author

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 ?

@Kev-Roche , it's done.

@chafique-delli chafique-delli force-pushed the 14.0-ADD-sale_certificat_typology branch from f24b1bd to f6af44a Compare October 5, 2023 08:55
@chafique-delli
Copy link
Member Author

@Kev-Roche , the changes made, are ok for you?

Comment on lines 15 to 40
@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",
)
Copy link
Member

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

Suggested change
@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(
Copy link
Member

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

Copy link
Member Author

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.

Comment on lines 116 to 121
product_ids = fields.Many2many(
comodel_name="product.product",
string="Concerned products",
compute="_compute_product_ids",
readonly=False,
)
Copy link
Member

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"

Copy link
Member Author

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.

Comment on lines 113 to 115
order_line_ids = fields.Many2many(
comodel_name="sale.order.line", string="Linked order lines", required=True
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

Copy link
Member Author

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.

@chafique-delli chafique-delli force-pushed the 14.0-ADD-sale_certificat_typology branch from cae5511 to 96ee09c Compare December 1, 2023 18:32
@chafique-delli chafique-delli force-pushed the 14.0-ADD-sale_certificat_typology branch from 96ee09c to 83a13ad Compare December 6, 2023 09:44
@Kev-Roche Kev-Roche force-pushed the 14.0-ADD-sale_certificat_typology branch from 157f367 to 9cdfd90 Compare October 29, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants