Skip to content

Commit

Permalink
Merge PR #1088 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by dhongu
  • Loading branch information
OCA-git-bot committed Oct 14, 2024
2 parents 971a3cb + ac1f644 commit bb316de
Show file tree
Hide file tree
Showing 8 changed files with 593 additions and 146 deletions.
9 changes: 9 additions & 0 deletions l10n_ro_config/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ class ResCompany(models.Model):
"a non deductible account set, this account will be used.",
)

l10n_ro_print_delivery_price = fields.Boolean(
string="Print Delivery Slip Prices and Totals",
help="For delivery order to customer or intern transfer order, this variable sets "
"whether if the unit price and total are printed on the delivery slip"
"Default is enabled, the system will automatically print these values"
"on the delivery note.",
default=True,
)

def _check_is_l10n_ro_record(self, company=False):
if not company:
company = self
Expand Down
4 changes: 4 additions & 0 deletions l10n_ro_config/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class ResConfigSettings(models.TransientModel):
l10n_ro_stock_acc_price_diff = fields.Boolean(
related="company_id.l10n_ro_stock_acc_price_diff", readonly=False
)
l10n_ro_print_delivery_price = fields.Boolean(
related="company_id.l10n_ro_print_delivery_price",
readonly=False,
)
l10n_ro_property_stock_price_difference_product_id = fields.Many2one(
"product.product",
related="company_id.l10n_ro_property_stock_price_difference_product_id",
Expand Down
16 changes: 16 additions & 0 deletions l10n_ro_config/views/res_config_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,22 @@
<div class="text-muted">
Add valued reports for stock operations.
</div>
<div
class="o_setting_left_pane"
attrs="{'invisible': [('module_l10n_ro_stock_picking_valued_report', '=', False)]}"
>
<field name="l10n_ro_print_delivery_price" />
</div>
<div
class="o_setting_right_pane"
attrs="{'invisible': [('module_l10n_ro_stock_picking_valued_report', '=', False)]}"
>
<label for="l10n_ro_print_delivery_price" />
<div class="text-muted">
For delivery order to customer or intern transfer order, this variable sets
whether if the unit price and total are printed on the delivery slip.
</div>
</div>
</div>
</div>
<div
Expand Down
86 changes: 75 additions & 11 deletions l10n_ro_stock_picking_valued_report/models/stock_move_line.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (C) 2022 NextERP Romania
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).


from odoo import api, fields, models


Expand Down Expand Up @@ -59,6 +60,7 @@ def _compute_l10n_ro_valued_fields(self):
for line in self:
move_qty = line._get_move_line_quantity()
line.l10n_ro_additional_charges = 0
kit = False
if line.l10n_ro_sale_line_id:
sale_line = line.l10n_ro_sale_line_id
line.l10n_ro_currency_id = sale_line.currency_id
Expand All @@ -70,20 +72,60 @@ def _compute_l10n_ro_valued_fields(self):
line.l10n_ro_price_unit = sale_line.product_uom._compute_price(
price_unit, line.product_uom_id
)
line.l10n_ro_price_subtotal = move_qty * line.l10n_ro_price_unit
line.l10n_ro_price_tax = (
(sale_line.price_tax / sale_line.product_uom_qty) * move_qty
if sale_line.product_uom_qty
else 0
)
line.l10n_ro_price_total = (
(sale_line.price_total / sale_line.product_uom_qty) * move_qty
if sale_line.product_uom_qty
else 0

sale_mrp = (
self.env["ir.module.module"]
.sudo()
.search(
[("name", "=", "sale_mrp"), ("state", "=", "installed")],
limit=1,
)
)

if sale_mrp:
if len(line.l10n_ro_sale_line_id.move_ids[0].bom_line_id) != 0:
qty_kit = line.move_id.bom_line_id.product_qty

unit_price = (
line.l10n_ro_sale_line_id.price_subtotal
/ (
len(line.l10n_ro_sale_line_id.move_ids)
* line.l10n_ro_sale_line_id.product_uom_qty
* qty_kit
)
if sale_line.product_uom_qty and qty_kit
else 0
)
line.l10n_ro_price_unit = unit_price
taxes = line.l10n_ro_sale_line_id.tax_id.compute_all(
unit_price,
line.l10n_ro_sale_line_id.currency_id,
move_qty,
line.move_id.bom_line_id.product_id,
self.l10n_ro_sale_line_id.order_id.partner_id,
)
kit = True

line.l10n_ro_price_subtotal = move_qty * line.l10n_ro_price_unit
if kit:
line.l10n_ro_price_tax = taxes["taxes"][0]["amount"]
line.l10n_ro_price_total = (
line.l10n_ro_price_subtotal + line.l10n_ro_price_tax
)
else:
line.l10n_ro_price_tax = (
(sale_line.price_tax / sale_line.product_uom_qty) * move_qty
if sale_line.product_uom_qty
else 0
)
line.l10n_ro_price_total = (
(sale_line.price_total / sale_line.product_uom_qty) * move_qty
if sale_line.product_uom_qty
else 0
)
else:
svls = line.move_id.stock_valuation_layer_ids

svls = line.move_id.stock_valuation_layer_ids
svls_lc_not_same_invoice = self.env["stock.valuation.layer"]
price_unit = 0
if svls:
Expand Down Expand Up @@ -112,13 +154,35 @@ def _compute_l10n_ro_valued_fields(self):
)
line.l10n_ro_price_subtotal = move_qty * line.l10n_ro_price_unit
line.l10n_ro_price_tax = 0
purchase_mrp = (
self.env["ir.module.module"]
.sudo()
.search(
[("name", "=", "purchase_mrp"), ("state", "=", "installed")],
limit=1,
)
)

if purchase_mrp:
if line.l10n_ro_purchase_line_id and line.move_id.bom_line_id:
taxes = line.l10n_ro_purchase_line_id.taxes_id.compute_all(
price_unit,
line.l10n_ro_purchase_line_id.currency_id,
move_qty,
line.move_id.bom_line_id.product_id,
line.l10n_ro_purchase_line_id.order_id.partner_id,
)
kit = True

if line.l10n_ro_purchase_line_id and svls:
price_tax = (
line.l10n_ro_purchase_line_id.price_tax
/ line.l10n_ro_purchase_line_id.product_uom_qty
if line.l10n_ro_purchase_line_id.product_uom_qty
else line.l10n_ro_purchase_line_id.price_tax
) * move_qty
if kit:
price_tax = taxes["taxes"][0]["amount"]
line.l10n_ro_price_tax = (
line.l10n_ro_purchase_line_id.currency_id._convert(
price_tax,
Expand Down
Loading

0 comments on commit bb316de

Please sign in to comment.