Compare commits

...

4 Commits

Author SHA1 Message Date
Raphaël Valyi
b378bc6f48 down payment with original taxes 2022-05-03 04:09:00 -03:00
beau sebastien
d3989e96d7 Merge pull request #171 from akretion/14.0-account-usability-add-balance
[IMP] add balance
2022-05-02 16:36:03 +02:00
Kev-Roche
f1a0aa6253 pos_usability : add pos initial amount 2022-04-27 22:02:38 +02:00
Sébastien BEAU
a59c2e774a [IMP] add balance 2022-04-11 13:43:40 +02:00
6 changed files with 67 additions and 0 deletions

View File

@@ -242,6 +242,17 @@ class AccountMoveLine(models.Model):
compute='_compute_reconcile_string', string='Reconcile', store=True)
# for optional display in tree view
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
balance = fields.Monetary(
string='Balance',
default=0.0,
currency_field='company_currency_id',
compute="_compute_balance",
store=True)
@api.depends("credit", "debit")
def _compute_balance(self):
for line in self:
line.balance = line.debit - line.credit
def show_account_move_form(self):
self.ensure_one()

View File

@@ -70,6 +70,9 @@
<field name="matching_number" position="after">
<button title="View Journal Entry Form" type="object" name="show_account_move_form" icon="fa-arrow-right"/>
</field>
<field name="credit" position="after">
<field name="balance" sum="Balance" />
</field>
</field>
</record>

View File

@@ -15,6 +15,20 @@
<button name="show_journal_items" position="after">
<button name="%(point_of_sale.action_report_pos_order_all)d" type="action" class="oe_stat_button" icon="fa-table" string="Stats" context="{'search_default_session_id': active_id}"/>
</button>
<xpath
expr="//field[@name='cash_register_total_entry_encoding']/parent::group"
position="before"
>
<group>
<field
style="text-align:right;margin:0;padding:0;"
name="cash_register_balance_start"
widget="monetary"
options="{'currency_field': 'currency_id'}"
string="Starting Balance"
/>
</group>
</xpath>
</field>
</record>

View File

@@ -1 +1,2 @@
from . import models
from . import wizard

View File

@@ -0,0 +1 @@
from . import sale_make_invoice_advance

View File

@@ -0,0 +1,37 @@
from odoo import models
from odoo.tools import float_is_zero
class SaleAdvancePaymentInv(models.TransientModel):
_inherit = "sale.advance.payment.inv"
def _prepare_invoice_values(self, order, name, amount, so_line):
"""
Create as many invoice lines as order lines with their original
order line taxes. Lines quantities have the ratio of the advance payment.
"""
invoice_vals = super()._prepare_invoice_values(order, name, amount, so_line)
lines = []
uom_precision_digits = self.env["decimal.precision"].precision_get(
"Product Unit of Measure"
)
for line in order.order_line:
if (
not float_is_zero(
# avoids taking lines like previous advance payments
line.product_uom_qty, precision_digits=uom_precision_digits
)
):
lines.append((0, 0, {
"name": name,
"price_unit": line.price_unit,
"quantity": line.product_uom_qty * amount / order.amount_total,
"product_id": line.product_id.id,
"product_uom_id": line.product_uom.id,
"tax_ids": [(6, 0, line.tax_id.ids)],
"sale_line_ids": [(6, 0, [line.id])],
"analytic_tag_ids": [(6, 0, line.analytic_tag_ids.ids)],
"analytic_account_id": order.analytic_account_id.id or False,
}))
invoice_vals["invoice_line_ids"] = lines
return invoice_vals