Browse Source
[FIX] The backend now handles properly the fiscal position conversion of taxes applied on the frontend
pull/39/head
[FIX] The backend now handles properly the fiscal position conversion of taxes applied on the frontend
pull/39/head
PabloCM
9 years ago
7 changed files with 229 additions and 1 deletions
-
11pos_pricelist/__init__.py
-
4pos_pricelist/__openerp__.py
-
30pos_pricelist/migrations/8.0.1.1.0/post-migration.py
-
1pos_pricelist/models/__init__.py
-
62pos_pricelist/models/point_of_sale.py
-
14pos_pricelist/static/src/js/models.js
-
108pos_pricelist/views/point_of_sale_view.xml
@ -0,0 +1,30 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Copyright (C) 2015 Aserti Global Solutions (http://www.aserti.es/). |
||||
|
# |
||||
|
# This program is free software: you can redistribute it and/or modify |
||||
|
# it under the terms of the GNU Affero General Public License as published |
||||
|
# by the Free Software Foundation, either version 3 of the License, or |
||||
|
# (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
__name__ = ("Copy the product taxes to the pos.line") |
||||
|
|
||||
|
|
||||
|
def migrate(cr, version): |
||||
|
cr.execute("""insert into pline_tax_rel |
||||
|
select l.id, t.id |
||||
|
from pos_order_line l |
||||
|
join pos_order o on l.order_id = o.id |
||||
|
join product_taxes_rel rel on rel.prod_id = l.product_id |
||||
|
join account_tax t on rel.tax_id = t.id |
||||
|
where t.company_id = o.company_id""") |
@ -0,0 +1,62 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Copyright (C) 2015 Aserti Global Solutions (http://www.aserti.es/). |
||||
|
# |
||||
|
# This program is free software: you can redistribute it and/or modify |
||||
|
# it under the terms of the GNU Affero General Public License as published |
||||
|
# by the Free Software Foundation, either version 3 of the License, or |
||||
|
# (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
|
||||
|
|
||||
|
from openerp import models, fields, api |
||||
|
# import logging |
||||
|
# _logger = logging.getLogger(__name__) |
||||
|
|
||||
|
|
||||
|
class PosOrderLine(models.Model): |
||||
|
_inherit = "pos.order.line" |
||||
|
|
||||
|
@api.one |
||||
|
@api.depends('tax_ids', 'qty', 'price_unit', |
||||
|
'product_id', 'discount', 'order_id.partner_id') |
||||
|
def _amount_line_all(self): |
||||
|
price = self.price_unit * (1 - (self.discount or 0.0) / 100.0) |
||||
|
taxes = self.tax_ids.compute_all( |
||||
|
price, self.qty, product=self.product_id, |
||||
|
partner=self.order_id.partner_id) |
||||
|
self.price_subtotal = taxes['total'] |
||||
|
self.price_subtotal_incl = taxes['total_included'] |
||||
|
|
||||
|
tax_ids = fields.Many2many( |
||||
|
'account.tax', 'pline_tax_rel', 'pos_line_id', 'tax_id', |
||||
|
"Taxes", domain=[('type_tax_use', '=', 'sale')]) |
||||
|
price_subtotal = fields.Float(compute="_amount_line_all", store=True) |
||||
|
price_subtotal_incl = fields.Float(compute="_amount_line_all", store=True) |
||||
|
|
||||
|
|
||||
|
class PosOrder(models.Model): |
||||
|
_inherit = "pos.order" |
||||
|
|
||||
|
@api.model |
||||
|
def _amount_line_tax(self, line): |
||||
|
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0) |
||||
|
taxes = line.tax_ids.compute_all( |
||||
|
price, line.qty, product=line.product_id, |
||||
|
partner=line.order_id.partner_id)['taxes'] |
||||
|
val = 0.0 |
||||
|
for c in taxes: |
||||
|
val += c.get('amount', 0.0) |
||||
|
return val |
||||
|
|
||||
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
@ -0,0 +1,108 @@ |
|||||
|
<?xml version="1.0"?> |
||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<record id="view_pos_pos_form" model="ir.ui.view"> |
||||
|
<field name="name">pos.order</field> |
||||
|
<field name="model">pos.order</field> |
||||
|
<field name="inherit_id" ref="point_of_sale.view_pos_pos_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//field[@name='lines']/tree/field[@name='discount']" position="after"> |
||||
|
<field name="tax_ids" widget="many2many_tags"/> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
<!-- |
||||
|
<record model="ir.ui.view" id="view_pos_pos_form"> |
||||
|
<field name="name">pos.order</field> |
||||
|
<field name="model">pos.order</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Point of Sale Orders"> |
||||
|
<header> |
||||
|
<button name="%(action_pos_payment)d" string="Payment" class="oe_highlight" type="action" states="draft" context="{'pos_session_id' : session_id}"/> |
||||
|
<button name="action_invoice" string="Invoice" type="object" states="paid" attrs="{'readonly': [('partner_id','=',False)]}"/> |
||||
|
<button name="refund" string="Return Products" type="object" |
||||
|
attrs="{'invisible':[('state','=','draft')]}"/> |
||||
|
<button name="%(action_report_pos_receipt)d" string="Reprint" type="action" states="paid,done,invoiced"/> |
||||
|
<field name="state" widget="statusbar" statusbar_visible="draft,paid,done" statusbar_colors='{"cancel":"red"}'/> |
||||
|
</header> |
||||
|
<sheet> |
||||
|
<group col="4" colspan="4"> |
||||
|
<field name="name"/> |
||||
|
<field name="date_order"/> |
||||
|
<field name="session_id" required="1"/> |
||||
|
<field name="partner_id" on_change="onchange_partner_id(partner_id, context)" domain="[('customer', '=', True)]" context="{'search_default_customer':1}" attrs="{'readonly': [('state','=','invoiced')]}"/> |
||||
|
</group> |
||||
|
<notebook colspan="4"> |
||||
|
<page string="Products"> |
||||
|
<field name="lines" colspan="4" nolabel="1"> |
||||
|
<tree string="Order lines" editable="bottom"> |
||||
|
<field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,qty,parent.partner_id)"/> |
||||
|
<field name="qty" on_change="onchange_qty(product_id, discount, qty, price_unit, context)"/> |
||||
|
<field name="price_unit" on_change="onchange_qty(product_id, discount, qty, price_unit, context)"/> |
||||
|
<field name="discount" on_change="onchange_qty(product_id, discount, qty, price_unit, context)"/> |
||||
|
<field name="price_subtotal"/> |
||||
|
<field name="price_subtotal_incl"/> |
||||
|
</tree> |
||||
|
<form string="Order lines"> |
||||
|
<group col="4"> |
||||
|
<field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,qty,parent.partner_id)"/> |
||||
|
<field name="qty" on_change="onchange_qty(product_id, discount, qty, price_unit, context)"/> |
||||
|
<field name="discount" on_change="onchange_qty(product_id, discount, qty, price_unit, context)"/> |
||||
|
<field name="price_unit" on_change="onchange_qty(product_id, discount, qty, price_unit, context)"/> |
||||
|
<field name="price_subtotal" invisible="1"/> |
||||
|
<field name="price_subtotal_incl" invisible="1"/> |
||||
|
<field name="notice"/> |
||||
|
</group> |
||||
|
</form> |
||||
|
</field> |
||||
|
<group class="oe_subtotal_footer oe_right" colspan="2" name="order_total"> |
||||
|
<field name="amount_tax"/> |
||||
|
<div class="oe_subtotal_footer_separator oe_inline"> |
||||
|
<label for="amount_total" /> |
||||
|
<button name="button_dummy" |
||||
|
states="draft" string="(update)" class="oe_edit_only oe_link"/> |
||||
|
</div> |
||||
|
<field name="amount_total" nolabel="1" class="oe_subtotal_footer_separator"/> |
||||
|
</group> |
||||
|
<div class="oe_clear"/> |
||||
|
</page> |
||||
|
<page string="Payments"> |
||||
|
<field name="statement_ids" colspan="4" nolabel="1"> |
||||
|
<tree editable="bottom" string="Statement lines"> |
||||
|
<field name="journal_id"/> |
||||
|
<field name="statement_id"/> |
||||
|
<field name="amount"/> |
||||
|
</tree> |
||||
|
</field> |
||||
|
</page> |
||||
|
<page string="Extra Info"> |
||||
|
<group string="General Information"> |
||||
|
<field name="company_id" groups="base.group_multi_company"/> |
||||
|
<field name="location_id" widget="selection" groups="stock.group_locations"/> |
||||
|
<field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'point_of_sale.group_pos_user']}"/> |
||||
|
<field name="pricelist_id" groups="product.group_sale_pricelist" domain="[('type','=','sale')]"/> |
||||
|
<field name="picking_id" readonly="1"/> |
||||
|
<field name="pos_reference"/> |
||||
|
</group> |
||||
|
<group string="Accounting Information"> |
||||
|
<field name="sale_journal" domain="[('type','=','sale')]"/> |
||||
|
<field name="invoice_id" readonly="1" |
||||
|
attrs="{'invisible':[('state','<>','invoiced')]}"/> |
||||
|
<button name="%(pos_invoice_report)d" string="Re-Print" |
||||
|
icon="gtk-print" type="action" attrs="{'invisible':[('state','<>','invoiced')]}"/> |
||||
|
<field name="account_move" readonly="1" |
||||
|
attrs="{'invisible':[('state','<>','done')]}"/> |
||||
|
</group> |
||||
|
</page> |
||||
|
<page string="Notes" > |
||||
|
<field name="note"/> |
||||
|
</page> |
||||
|
</notebook> |
||||
|
</sheet> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
--> |
||||
|
</data> |
||||
|
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue