Skip to content

Commit

Permalink
[REM] barcodes_gs1_label: remove gs1_generated field
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankC013 committed Feb 13, 2024
1 parent 5519942 commit 41de047
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 58 deletions.
17 changes: 1 addition & 16 deletions barcodes_gs1_label/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# Frank Cespedes <fcespedes@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import _, api, models
from odoo.exceptions import ValidationError
from odoo import models


class ProductProduct(models.Model):
Expand All @@ -15,17 +14,3 @@ def print_gs1_barcode_wizard(self):
"barcodes_gs1_label.barcodes_product_option_wizard_view_action"
)
return action

@api.constrains("barcode")
def _check_barcode(self):
for rec in self:
lot = rec.env["stock.production.lot"].search(
[("product_id", "=", rec.id), ("gs1_generated", "=", True)],
)
if lot:
raise ValidationError(
_(
"Exists a lot %s with a GS1 generated, the "
"barcode cannot be modified" % lot.mapped("name")
)
)
26 changes: 1 addition & 25 deletions barcodes_gs1_label/models/stock_production_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo import models


class ProductionLot(models.Model):
Expand All @@ -14,26 +13,3 @@ def print_gs1_barcode_wizard(self):
"barcodes_gs1_label.barcodes_lot_option_wizard_view_action"
)
return action

gs1_generated = fields.Boolean()

@api.onchange("gs1_generated")
def _onchange_gs1_generated(self):
if not self.gs1_generated and self._origin.id:
return {
"warning": {
"title": _("Warning"),
"message": _("A GS1 code has been generated with this data."),
},
}

@api.constrains("name", "ref")
def _check_name(self):
for rec in self:
if rec.gs1_generated:
raise ValidationError(
_(
"If the lot has a GS1 generated, the Lot/Serial "
"Number and Internal Reference cannot be modified"
)
)
2 changes: 0 additions & 2 deletions barcodes_gs1_label/report/report_barcode_gs1.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ def _get_report_values(self, docids, data=None): # noqa: C901
res.append(fnc1)

Check warning on line 257 in barcodes_gs1_label/report/report_barcode_gs1.py

View check run for this annotation

Codecov / codecov/patch

barcodes_gs1_label/report/report_barcode_gs1.py#L257

Added line #L257 was not covered by tests
doc["barcode_values"] = gs1_barcode
doc["barcode_string"] = requests.utils.quote("".join(res))

Check warning on line 259 in barcodes_gs1_label/report/report_barcode_gs1.py

View check run for this annotation

Codecov / codecov/patch

barcodes_gs1_label/report/report_barcode_gs1.py#L259

Added line #L259 was not covered by tests
if lot:
lot.gs1_generated = True
elif barcode_type == "ean13-code128":
doc["barcode_values"] = (
product.barcode or None,
Expand Down
15 changes: 0 additions & 15 deletions barcodes_gs1_label/views/stock_production_lot_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,6 @@
/>
</header>
</xpath>
<group name="main_group" position="after">
<group>
<field name="gs1_generated" />
</group>
</group>
<xpath expr="//field[@name='name']" position="attributes">
<attribute
name="attrs"
>{'readonly': [('gs1_generated', '=', True)]}</attribute>
</xpath>
<xpath expr="//field[@name='ref']" position="attributes">
<attribute
name="attrs"
>{'readonly': [('gs1_generated', '=', True)]}</attribute>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 41de047

Please sign in to comment.