Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] purchase_stock: AVCO computation - support line discount #79

Open
wants to merge 17 commits into
base: 16.0-alc_master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include requirements.txt
include LICENSE
include README.md
include pyproject.toml
include setup/pep517_odoo.py
graft odoo
recursive-exclude * *.py[co]
recursive-exclude .git *
2 changes: 1 addition & 1 deletion addons/product_expiry/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _auto_init(self):
create_column(self._cr, "stock_move_line", "expiration_date", "timestamp")
return super()._auto_init()

@api.depends('product_id', 'picking_type_use_create_lots', 'lot_id.expiration_date')
@api.depends('product_id', 'lot_id.expiration_date')
def _compute_expiration_date(self):
for move_line in self:
if move_line.lot_id.expiration_date:
Expand Down
13 changes: 8 additions & 5 deletions addons/purchase_stock/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ def _get_price_unit(self):
invoiced_value = 0
invoiced_qty = 0
for invoice_line in line.sudo().invoice_lines:
if invoice_line.tax_ids:
invoiced_value += invoice_line.tax_ids.with_context(round=False).compute_all(
invoice_line.price_unit, currency=invoice_line.currency_id, quantity=invoice_line.quantity)['total_void']
else:
invoiced_value += invoice_line.price_unit * invoice_line.quantity
# FIX je@bcim.be - Use discounted untaxed sub-total in price unit used for avco computation
# Current odoo computation is missing the line discount
invoiced_value += invoice_line.price_subtotal
# if invoice_line.tax_ids:
# invoiced_value += invoice_line.tax_ids.with_context(round=False).compute_all(
# invoice_line.price_unit, currency=invoice_line.currency_id, quantity=invoice_line.quantity)['total_void']
# else:
# invoiced_value += invoice_line.price_unit * invoice_line.quantity
invoiced_qty += invoice_line.product_uom_id._compute_quantity(invoice_line.quantity, line.product_id.uom_id)
# TODO currency check
remaining_value = invoiced_value - receipt_value
Expand Down
2 changes: 1 addition & 1 deletion addons/stock/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def action_open_quants(self):
)
else:
self = self.with_context(product_tmpl_ids=self.product_tmpl_id.ids)
action = self.env['stock.quant'].action_view_inventory()
action = self.with_context(quant_product_ids=self.ids).env['stock.quant'].action_view_inventory()
# note that this action is used by different views w/varying customizations
if not self.env.context.get('is_stock_report'):
action['domain'] = [('product_id', 'in', self.ids)]
Expand Down
6 changes: 6 additions & 0 deletions addons/stock/models/stock_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,12 @@ def _merge_quants(self):
AND product_id in %s
"""
params = [tuple(self.location_id.ids), tuple(self.product_id.ids)]
elif "quant_product_ids" in self.env.context:
query += """
WHERE
product_id in %s
"""
params = [tuple(self.env.context['quant_product_ids'])]
query += """
GROUP BY product_id, company_id, location_id, lot_id, package_id, owner_id
HAVING count(id) > 1
Expand Down
4 changes: 0 additions & 4 deletions addons/test_mail_sms/__init__.py

This file was deleted.

22 changes: 0 additions & 22 deletions addons/test_mail_sms/__manifest__.py

This file was deleted.

4 changes: 0 additions & 4 deletions addons/test_mail_sms/models/__init__.py

This file was deleted.

172 changes: 0 additions & 172 deletions addons/test_mail_sms/models/test_mail_sms_models.py

This file was deleted.

13 changes: 0 additions & 13 deletions addons/test_mail_sms/security/ir.model.access.csv

This file was deleted.

12 changes: 0 additions & 12 deletions addons/test_mail_sms/tests/__init__.py

This file was deleted.

22 changes: 0 additions & 22 deletions addons/test_mail_sms/tests/common.py

This file was deleted.

Loading