Browse Source

Merge PR #423 into 12.0

Signed-off-by legalsylvain
pull/473/head
OCA-git-bot 5 years ago
parent
commit
d6ba2cd12f
  1. 1
      pos_margin/__manifest__.py
  2. 28
      pos_margin/i18n/fr.po
  3. 14
      pos_margin/i18n/pos_margin.pot
  4. 21
      pos_margin/models/pos_order.py
  5. 30
      pos_margin/models/pos_order_line.py
  6. 6
      pos_margin/readme/USAGE.rst
  7. BIN
      pos_margin/static/description/pos_order_form.png
  8. BIN
      pos_margin/static/description/pos_order_tree.png
  9. 8
      pos_margin/views/view_pos_order.xml

1
pos_margin/__manifest__.py

@ -9,6 +9,7 @@
'category': 'Point Of Sale', 'category': 'Point Of Sale',
'author': "GRAP," 'author': "GRAP,"
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"maintainers": ["legalsylvain"],
'website': 'https://github.com/OCA/pos', 'website': 'https://github.com/OCA/pos',
'license': 'AGPL-3', 'license': 'AGPL-3',
'depends': [ 'depends': [

28
pos_margin/i18n/fr.po

@ -6,11 +6,10 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 12.0\n" "Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-15 11:05+0000\n"
"PO-Revision-Date: 2019-08-15 11:05+0000\n"
"POT-Creation-Date: 2019-12-12 10:19+0000\n"
"PO-Revision-Date: 2019-12-12 10:19+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
@ -23,12 +22,8 @@ msgstr "Prix de revient"
#. module: pos_margin #. module: pos_margin
#: model:ir.model.fields,help:pos_margin.field_pos_order__margin #: model:ir.model.fields,help:pos_margin.field_pos_order__margin
msgid ""
"It gives profitability by calculating the difference between the Unit Price "
"and the cost price."
msgstr ""
"Il donne la rentabilité en calculant la différence entre le prix unitaire et "
"le prix de revient."
msgid "It gives profitability by calculating the difference between the Unit Price and the cost price."
msgstr "Il donne la rentabilité en calculant la différence entre le prix unitaire et le prix de revient."
#. module: pos_margin #. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_pos_order__margin #: model:ir.model.fields,field_description:pos_margin.field_pos_order__margin
@ -36,6 +31,12 @@ msgstr ""
msgid "Margin" msgid "Margin"
msgstr "Marge" msgstr "Marge"
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_pos_order__margin_percent
#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line__margin_percent
msgid "Margin (%)"
msgstr "Marge (%)"
#. module: pos_margin #. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_rate #: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_rate
msgid "Margin Rate" msgid "Margin Rate"
@ -43,7 +44,6 @@ msgstr "Taux de marque"
#. module: pos_margin #. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_total #: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_total
#: model_terms:ir.ui.view,arch_db:pos_margin.view_pos_order_tree
msgid "Margin Total" msgid "Margin Total"
msgstr "Marge Totale" msgstr "Marge Totale"
@ -60,4 +60,10 @@ msgstr "Commandes du point de vente"
#. module: pos_margin #. module: pos_margin
#: model:ir.model,name:pos_margin.model_report_pos_order #: model:ir.model,name:pos_margin.model_report_pos_order
msgid "Point of Sale Orders Report" msgid "Point of Sale Orders Report"
msgstr ""
msgstr "Rapport sur les commandes au point de vente"
#. module: pos_margin
#: model_terms:ir.ui.view,arch_db:pos_margin.view_pos_order_tree
msgid "Total"
msgstr "Total"

14
pos_margin/i18n/pos_margin.pot

@ -6,6 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 12.0\n" "Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-12 10:18+0000\n"
"PO-Revision-Date: 2019-12-12 10:18+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -29,6 +31,12 @@ msgstr ""
msgid "Margin" msgid "Margin"
msgstr "" msgstr ""
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_pos_order__margin_percent
#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line__margin_percent
msgid "Margin (%)"
msgstr ""
#. module: pos_margin #. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_rate #: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_rate
msgid "Margin Rate" msgid "Margin Rate"
@ -36,7 +44,6 @@ msgstr ""
#. module: pos_margin #. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_total #: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_total
#: model_terms:ir.ui.view,arch_db:pos_margin.view_pos_order_tree
msgid "Margin Total" msgid "Margin Total"
msgstr "" msgstr ""
@ -55,3 +62,8 @@ msgstr ""
msgid "Point of Sale Orders Report" msgid "Point of Sale Orders Report"
msgstr "" msgstr ""
#. module: pos_margin
#: model_terms:ir.ui.view,arch_db:pos_margin.view_pos_order_tree
msgid "Total"
msgstr ""

21
pos_margin/models/pos_order.py

@ -11,14 +11,29 @@ class PosOrder(models.Model):
# Columns Section # Columns Section
margin = fields.Float( margin = fields.Float(
'Margin', compute='_compute_margin', store=True,
string='Margin',
compute='_compute_margin',
store=True,
digits=dp.get_precision('Product Price'), digits=dp.get_precision('Product Price'),
help="It gives profitability by calculating the difference between" help="It gives profitability by calculating the difference between"
" the Unit Price and the cost price.") " the Unit Price and the cost price.")
margin_percent = fields.Float(
string='Margin (%)',
compute='_compute_margin',
store=True,
digits=dp.get_precision('Product Price'),
)
# Compute Section # Compute Section
@api.multi @api.multi
@api.depends('lines.margin')
@api.depends('lines.margin', 'lines.price_subtotal')
def _compute_margin(self): def _compute_margin(self):
for order in self: for order in self:
order.margin = sum(order.mapped('lines.margin'))
tmp_margin = sum(order.mapped('lines.margin'))
tmp_price_subtotal = sum(order.mapped('lines.price_subtotal'))
order.update({
'margin': tmp_margin,
'margin_percent': tmp_price_subtotal and (
tmp_margin / tmp_price_subtotal * 100) or 0.0,
})

30
pos_margin/models/pos_order_line.py

@ -11,12 +11,25 @@ class PosOrderLine(models.Model):
# Columns Section # Columns Section
margin = fields.Float( margin = fields.Float(
'Margin', compute='_compute_multi_margin', store=True,
multi='multi_margin', digits=dp.get_precision('Product Price'))
string='Margin',
compute='_compute_multi_margin',
store=True,
digits=dp.get_precision('Product Price'),
)
margin_percent = fields.Float(
string='Margin (%)',
compute='_compute_multi_margin',
store=True,
digits=dp.get_precision('Product Price'),
)
purchase_price = fields.Float( purchase_price = fields.Float(
'Cost Price', compute='_compute_multi_margin', store=True,
multi='multi_margin', digits=dp.get_precision('Product Price'))
string='Cost Price',
compute='_compute_multi_margin',
store=True,
digits=dp.get_precision('Product Price'),
)
# Compute Section # Compute Section
@api.multi @api.multi
@ -24,8 +37,13 @@ class PosOrderLine(models.Model):
def _compute_multi_margin(self): def _compute_multi_margin(self):
for line in self.filtered('product_id'): for line in self.filtered('product_id'):
purchase_price = self._get_purchase_price(line) purchase_price = self._get_purchase_price(line)
line.purchase_price = purchase_price
line.margin = line.price_subtotal - (purchase_price * line.qty)
margin = line.price_subtotal - (purchase_price * line.qty)
line.update({
'purchase_price': purchase_price,
'margin': margin,
'margin_percent': line.price_subtotal and (
margin / line.price_subtotal * 100.0),
})
@api.model @api.model
def _get_purchase_price(self, line): def _get_purchase_price(self, line):

6
pos_margin/readme/USAGE.rst

@ -1,7 +1,13 @@
To use this module, you need to: To use this module, you need to:
* Go to 'Point Of Sale' / 'Orders' / 'Orders' * Go to 'Point Of Sale' / 'Orders' / 'Orders'
.. figure:: ../static/description/pos_order_tree.png
:width: 800px
* Open an order * Open an order
.. figure:: ../static/description/pos_order_form.png .. figure:: ../static/description/pos_order_form.png
:width: 800px :width: 800px

BIN
pos_margin/static/description/pos_order_form.png

Before

Width: 896  |  Height: 379  |  Size: 30 KiB

After

Width: 1122  |  Height: 500  |  Size: 69 KiB

BIN
pos_margin/static/description/pos_order_tree.png

After

Width: 1031  |  Height: 206  |  Size: 51 KiB

8
pos_margin/views/view_pos_order.xml

@ -13,9 +13,12 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="amount_total" position="after"> <field name="amount_total" position="after">
<field name="margin" widget="monetary"/> <field name="margin" widget="monetary"/>
<field name="margin_percent" widget="monetary"/>
</field> </field>
<xpath expr="//field[@name='lines']/tree/field[@name='price_unit']" position="after">
<xpath expr="//field[@name='lines']/tree/field[@name='discount']" position="after">
<field name="purchase_price" widget="monetary"/> <field name="purchase_price" widget="monetary"/>
<field name="margin"/>
<field name="margin_percent"/>
</xpath> </xpath>
</field> </field>
</record> </record>
@ -25,7 +28,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="inherit_id" ref="point_of_sale.view_pos_order_tree"/> <field name="inherit_id" ref="point_of_sale.view_pos_order_tree"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="amount_total" position="before"> <field name="amount_total" position="before">
<field name="margin" widget="monetary" sum="Margin Total"/>
<field name="margin" widget="monetary" sum="Total"/>
<field name="margin_percent" widget="monetary"/>
</field> </field>
</field> </field>
</record> </record>

Loading…
Cancel
Save