mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-25 02:12:01 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,9 @@
|
|||
from . import barcode_rule
|
||||
from . import pos_config
|
||||
from . import pos_order
|
||||
from . import pos_payment_method
|
||||
from . import pos_session
|
||||
from . import product_category
|
||||
from . import product_product
|
||||
from . import product_template
|
||||
from . import res_config_settings
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
|
||||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class BarcodeRule(models.Model):
|
||||
_inherit = "barcode.rule"
|
||||
|
||||
type = fields.Selection(
|
||||
selection_add=[("meal_voucher_payment", "Meal Voucher Payment")],
|
||||
ondelete={"meal_voucher_payment": "set default"},
|
||||
)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
|
||||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class PosConfig(models.Model):
|
||||
_inherit = "pos.config"
|
||||
|
||||
max_meal_voucher_amount = fields.Monetary(
|
||||
string="Meal Voucher Maximum Amount",
|
||||
currency_field="currency_id",
|
||||
)
|
||||
enable_meal_voucher_order_lines_icon = fields.Boolean(
|
||||
string="Meal Voucher Icon on Order Lines", default=True
|
||||
)
|
||||
enable_meal_voucher_receipt_info = fields.Boolean(
|
||||
string="Meal Voucher Information on Receipt",
|
||||
)
|
||||
has_meal_voucher_payment_method = fields.Boolean(
|
||||
compute="_compute_has_meal_voucher_payment_method"
|
||||
)
|
||||
|
||||
def _compute_has_meal_voucher_payment_method(self):
|
||||
for config in self:
|
||||
config.has_meal_voucher_payment_method = bool(
|
||||
config.payment_method_ids.filtered(
|
||||
lambda x: x.meal_voucher_type is not False
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
|
||||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class PosOrder(models.Model):
|
||||
_inherit = "pos.order"
|
||||
|
||||
def _payment_fields(self, order, ui_paymentline):
|
||||
res = super()._payment_fields(order, ui_paymentline)
|
||||
# the pos.payment.name field is named "Label" and is not used for
|
||||
# normal payments, so it is used here to store the payment note (the
|
||||
# barcode of paper meal vouchers).
|
||||
res["name"] = ui_paymentline.get("payment_note", False)
|
||||
return res
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
|
||||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class PosPaymentMethod(models.Model):
|
||||
_inherit = "pos.payment.method"
|
||||
|
||||
meal_voucher_type = fields.Selection(
|
||||
selection=[
|
||||
("paper", "Paper"),
|
||||
("electronic", "Electronic"),
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# SPDX-FileCopyrightText: 2025 Coop IT Easy SC
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class PosSession(models.Model):
|
||||
_inherit = "pos.session"
|
||||
|
||||
def _loader_params_pos_payment_method(self):
|
||||
res = super()._loader_params_pos_payment_method()
|
||||
res["search_params"]["fields"].append("meal_voucher_type")
|
||||
return res
|
||||
|
||||
def _loader_params_product_product(self):
|
||||
res = super()._loader_params_product_product()
|
||||
res["search_params"]["fields"].append("meal_voucher_ok")
|
||||
return res
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
|
||||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ProductCategory(models.Model):
|
||||
_inherit = "product.category"
|
||||
|
||||
meal_voucher_ok = fields.Boolean(
|
||||
string="Can be Paid for by Meal Vouchers",
|
||||
help="If checked, the products of this category will be marked as "
|
||||
'"Can be Paid for by Meal Vouchers" by default.',
|
||||
)
|
||||
|
||||
def button_apply_meal_voucher_settings(self):
|
||||
ProductTemplate = self.env["product.template"]
|
||||
for category in self:
|
||||
templates = (
|
||||
ProductTemplate.sudo()
|
||||
.with_context(active_test=False)
|
||||
.search([("categ_id", "=", category.id)])
|
||||
)
|
||||
templates.write({"meal_voucher_ok": category.meal_voucher_ok})
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# Copyright (C) 2021 - Today: GRAP (http://www.grap.coop)
|
||||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = "product.product"
|
||||
|
||||
@api.onchange("categ_id")
|
||||
def onchange_categ_id_pos_meal_voucher(self):
|
||||
for product in self:
|
||||
product.meal_voucher_ok = product.categ_id.meal_voucher_ok
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
|
||||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
|
||||
meal_voucher_ok = fields.Boolean(
|
||||
string="Can be Paid for by Meal Vouchers",
|
||||
help="Check this box if the product can be paid for by meal vouchers.",
|
||||
)
|
||||
|
||||
@api.onchange("categ_id")
|
||||
def onchange_categ_id_pos_meal_voucher(self):
|
||||
for template in self:
|
||||
template.meal_voucher_ok = template.categ_id.meal_voucher_ok
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
product_category_model = self.env["product.category"]
|
||||
for vals in vals_list:
|
||||
if "meal_voucher_ok" not in vals and "categ_id" in vals:
|
||||
# Guess meal_voucher_ok if not present, based on the category
|
||||
categ = product_category_model.browse(vals.get("categ_id"))
|
||||
vals["meal_voucher_ok"] = categ.meal_voucher_ok
|
||||
return super().create(vals_list)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# SPDX-FileCopyrightText: 2025 Coop IT Easy SC
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = "res.config.settings"
|
||||
|
||||
pos_max_meal_voucher_amount = fields.Monetary(
|
||||
related="pos_config_id.max_meal_voucher_amount",
|
||||
readonly=False,
|
||||
)
|
||||
pos_enable_meal_voucher_order_lines_icon = fields.Boolean(
|
||||
related="pos_config_id.enable_meal_voucher_order_lines_icon",
|
||||
readonly=False,
|
||||
)
|
||||
pos_enable_meal_voucher_receipt_info = fields.Boolean(
|
||||
related="pos_config_id.enable_meal_voucher_receipt_info",
|
||||
readonly=False,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue