This question has been flagged
1 Reply
3489 Views

Can Odoo allow me to create a Landed Cost Adjustment where I allocate the costs to SOME products?

My Vendor Bill lists charges already broken out by product, so when I buy five products I have five additional lines on the bill for the ocean freight, customs, duty, taxes, handling, crating, storage and inbound freight for each product.

After adding these five lines to the Bill, and then adding the same five lines to a Landed Cost Adjustment, Odoo wants me to allocate EVERY line to EVERY product.

I don't want to do an Adjustment per product - I want a single Adjustment for a single Inbound Delivery.

Avatar
Discard
Best Answer

The Python function _check_sum is called to check that you have distributed all costs over all products:

https://github.com/odoo/odoo/blob/10.0/addons/stock_landed_costs/models/stock_landed_cost.py#L137

Create your own module that replaces this function with one that doesn't check the distribution:

class LandedCost(models.Model):
     _inherit = 'stock.landed.cost'
    
    def _check_sum(self):
         """ Check if each cost line its valuation lines sum to the correct amount
         and if the overall total amount is correct also """
         prec_digits = self.env['decimal.precision'].precision_get('Account')
         for landed_cost in self:
             total_amount = sum(landed_cost.valuation_adjustment_lines.mapped('additional_landed_cost'))
             if not tools.float_compare(total_amount, landed_cost.amount_total, precision_digits=prec_digits) == 0:
                 return False

            # val_to_cost_lines = defaultdict(lambda: 0.0)
            # for val_line in landed_cost.valuation_adjustment_lines:
                # val_to_cost_lines[val_line.cost_line_id] += val_line.additional_landed_cost
            # if any(tools.float_compare(cost_line.price_unit, val_amount, precision_digits=prec_digits) != 0
                    # for cost_line, val_amount in val_to_cost_lines.iteritems()):
                # return False
return True

Avatar
Discard