[IMP] stock_account: add hook on anglosaxon dropshipping entries
The goal is to modify the acconuts that take please in those entries. A typical example is a company that wants to recognize cost of goods sold for the input and output at the same time, instead of waiting for the customer invoice. closes odoo/odoo#161505 X-original-commit: f477433a9092deb21236b90114759316b13bc1bc Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
committed by
William Henrotin
parent
1bca12c443
commit
bb0cb28962
@@ -591,23 +591,30 @@ class StockMove(models.Model):
|
||||
|
||||
if self.company_id.anglo_saxon_accounting:
|
||||
# Creates an account entry from stock_input to stock_output on a dropship move. https://github.com/odoo/odoo/issues/12687
|
||||
if self._is_dropshipped():
|
||||
if cost > 0:
|
||||
am_vals.append(self.with_company(self.company_id)._prepare_account_move_vals(acc_src, acc_valuation, journal_id, qty, description, svl_id, cost))
|
||||
else:
|
||||
cost = -1 * cost
|
||||
am_vals.append(self.with_company(self.company_id)._prepare_account_move_vals(acc_valuation, acc_dest, journal_id, qty, description, svl_id, cost))
|
||||
elif self._is_dropshipped_returned():
|
||||
if cost > 0 and self.location_dest_id._should_be_valued():
|
||||
am_vals.append(self.with_company(self.company_id).with_context(is_returned=True)._prepare_account_move_vals(acc_valuation, acc_src, journal_id, qty, description, svl_id, cost))
|
||||
elif cost > 0:
|
||||
am_vals.append(self.with_company(self.company_id).with_context(is_returned=True)._prepare_account_move_vals(acc_dest, acc_valuation, journal_id, qty, description, svl_id, cost))
|
||||
else:
|
||||
cost = -1 * cost
|
||||
am_vals.append(self.with_company(self.company_id).with_context(is_returned=True)._prepare_account_move_vals(acc_valuation, acc_src, journal_id, qty, description, svl_id, cost))
|
||||
anglosaxon_am_vals = self._prepare_anglosaxon_account_move_vals(acc_src, acc_dest, acc_valuation, journal_id, qty, description, svl_id, cost)
|
||||
if anglosaxon_am_vals:
|
||||
am_vals.append(anglosaxon_am_vals)
|
||||
|
||||
return am_vals
|
||||
|
||||
def _prepare_anglosaxon_account_move_vals(self, acc_src, acc_dest, acc_valuation, journal_id, qty, description, svl_id, cost):
|
||||
anglosaxon_am_vals = {}
|
||||
if self._is_dropshipped():
|
||||
if cost > 0:
|
||||
anglosaxon_am_vals = self.with_company(self.company_id)._prepare_account_move_vals(acc_src, acc_valuation, journal_id, qty, description, svl_id, cost)
|
||||
else:
|
||||
cost = -1 * cost
|
||||
anglosaxon_am_vals = self.with_company(self.company_id)._prepare_account_move_vals(acc_valuation, acc_dest, journal_id, qty, description, svl_id, cost)
|
||||
elif self._is_dropshipped_returned():
|
||||
if cost > 0 and self.location_dest_id._should_be_valued():
|
||||
anglosaxon_am_vals = self.with_company(self.company_id).with_context(is_returned=True)._prepare_account_move_vals(acc_valuation, acc_src, journal_id, qty, description, svl_id, cost)
|
||||
elif cost > 0:
|
||||
anglosaxon_am_vals = self.with_company(self.company_id).with_context(is_returned=True)._prepare_account_move_vals(acc_dest, acc_valuation, journal_id, qty, description, svl_id, cost)
|
||||
else:
|
||||
cost = -1 * cost
|
||||
anglosaxon_am_vals = self.with_company(self.company_id).with_context(is_returned=True)._prepare_account_move_vals(acc_valuation, acc_src, journal_id, qty, description, svl_id, cost)
|
||||
return anglosaxon_am_vals
|
||||
|
||||
def _get_analytic_distribution(self):
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user