forked from OCA/delivery-carrier
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move code that get SO from move to dedicated method
- Loading branch information
1 parent
a4d7690
commit e18851e
Showing
2 changed files
with
16 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,32 +3,23 @@ | |
# @author: Alexis de Lattre <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models, api | ||
from odoo import models | ||
from odoo.tools import float_is_zero | ||
|
||
|
||
class StockPackOperation(models.Model): | ||
_inherit = 'stock.pack.operation' | ||
|
||
@api.multi | ||
def _roulier_get_unit_price_for_customs(self): | ||
def get_unit_price_for_customs(self): | ||
"""This method is designed to be inherited for specific scenarios""" | ||
self.ensure_one() | ||
prec = self.env['decimal.precision'].precision_get( | ||
'Product Unit of Measure') | ||
if ( | ||
self.linked_move_operation_ids and | ||
self.linked_move_operation_ids[0].move_id and | ||
self.linked_move_operation_ids[0].move_id.procurement_id and | ||
self.linked_move_operation_ids[0].move_id.procurement_id. | ||
sale_line_id and | ||
not float_is_zero( | ||
self.linked_move_operation_ids[0].move_id.procurement_id. | ||
sale_line_id.product_uom_qty, precision_digits=prec)): | ||
sol = self.linked_move_operation_ids[0].move_id.\ | ||
procurement_id.sale_line_id | ||
price_unit_so_uom = sol.price_subtotal / sol.product_uom_qty | ||
price_unit = sol.product_uom._compute_price( | ||
soline = self.get_sale_order_line() | ||
if soline and not float_is_zero( | ||
soline.product_uom_qty, precision_digits=prec): | ||
price_unit_so_uom = soline.price_subtotal / soline.product_uom_qty | ||
price_unit = soline.product_uom._compute_price( | ||
price_unit_so_uom, self.product_uom_id) | ||
else: | ||
product = self.product_id | ||
|
@@ -37,3 +28,11 @@ def _roulier_get_unit_price_for_customs(self): | |
product.list_price, product.taxes_id, ato, | ||
self.picking_id.company_id) | ||
return price_unit | ||
|
||
def get_sale_order_line(self): | ||
soline = self.linked_move_operation_ids and\ | ||
self.linked_move_operation_ids[0].move_id and\ | ||
self.linked_move_operation_ids[0].move_id.procurement_id and\ | ||
self.linked_move_operation_ids[0].move_id.procurement_id.\ | ||
sale_line_id or False | ||
return soline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters