Skip to content

Commit

Permalink
Merge PR #952 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by legalsylvain
  • Loading branch information
OCA-git-bot committed Aug 6, 2023
2 parents 553a50b + 3350cc5 commit b0e8476
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 0 deletions.
Empty file.
1 change: 1 addition & 0 deletions pos_product_mergeable_line/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
23 changes: 23 additions & 0 deletions pos_product_mergeable_line/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2023-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).

{
"name": "Point of Sale - Mergeable Lines",
"summary": "Allows to configure at the product level,"
" if an order line can be merged or not.",
"version": "12.0.1.0.1",
"category": "Point of Sale",
"author": "GRAP, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"maintainers": ["legalsylvain"],
"depends": [
"point_of_sale",
],
"data": [
"views/templates.xml",
"views/view_product_template.xml",
],
"installable": True,
}
34 changes: 34 additions & 0 deletions pos_product_mergeable_line/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_product_mergeable_line
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-03-30 15:11+0000\n"
"PO-Revision-Date: 2023-03-30 15:11+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: pos_product_mergeable_line
#: model:ir.model.fields,help:pos_product_mergeable_line.field_product_product__pos_mergeable_line
#: model:ir.model.fields,help:pos_product_mergeable_line.field_product_template__pos_mergeable_line
msgid "If unchecked, the product will never be merged with a previous line, in the Point of sale."
msgstr "Si la case est décochée, l'article ne sera jamais regroupé avec la ligne précédente, dans le point de vente."

#. module: pos_product_mergeable_line
#: model:ir.model.fields,field_description:pos_product_mergeable_line.field_product_product__pos_mergeable_line
#: model:ir.model.fields,field_description:pos_product_mergeable_line.field_product_template__pos_mergeable_line
msgid "Mergeable Line"
msgstr "Ligne regroupable"

#. module: pos_product_mergeable_line
#: model:ir.model,name:pos_product_mergeable_line.model_product_template
msgid "Product Template"
msgstr "Modèle d'article"

1 change: 1 addition & 0 deletions pos_product_mergeable_line/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_template
16 changes: 16 additions & 0 deletions pos_product_mergeable_line/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) 2023-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 ProductTemplate(models.Model):
_inherit = "product.template"

pos_mergeable_line = fields.Boolean(
string="Mergeable Line",
default=True,
help="If unchecked, the product will never"
" be merged with a previous line, in the Point of sale.",
)
1 change: 1 addition & 0 deletions pos_product_mergeable_line/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Sylvain LE GAL <https://twitter.com/legalsylvain>
12 changes: 12 additions & 0 deletions pos_product_mergeable_line/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
This module extends the Odoo Point of Sale to prevent to merge lines if product
is configured.

By default, new line can be merged with a previous one if the informations are the same.
(same product, same restaurant note, etc...) and if the UoM Category allow it.

The new module add a boolean field 'Mergeable Line' (default True).

If unchecked, the product will never be merged into another line.

That's important in some context, as in the management of returnable products,
where we want to have a record of all movements.
26 changes: 26 additions & 0 deletions pos_product_mergeable_line/static/src/js/models.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright (C) 2023-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).
*/

odoo.define("pos_product_mergeable_line.models", function (require) {
"use strict";

const models = require("point_of_sale.models");

models.load_fields("product.product", ["pos_mergeable_line"]);

const OrderlineSuper = models.Orderline.prototype;

models.Orderline = models.Orderline.extend({
can_be_merged_with: function(orderline){
if (! orderline.product.pos_mergeable_line) {
return false;
}
return OrderlineSuper.can_be_merged_with.apply(this, arguments);
},
});

return models;
});
13 changes: 13 additions & 0 deletions pos_product_mergeable_line/views/templates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!--
Copyright 2023 - Today Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->

<odoo>
<template id="point_of_sale_assets" name="pos_product_mergeable_line" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_product_mergeable_line/static/src/js/models.js"></script>
</xpath>
</template>
</odoo>
17 changes: 17 additions & 0 deletions pos_product_mergeable_line/views/view_product_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
Copyright 2023 - Today Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>

<record id="view_product_template_form" model="ir.ui.view">
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<field name="to_weight" position="after">
<field name="pos_mergeable_line" />
</field>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/pos_product_mergeable_line/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit b0e8476

Please sign in to comment.