|
@ -12,11 +12,13 @@ from werkzeug import utils |
|
|
class SaleOrder(models.Model): |
|
|
class SaleOrder(models.Model): |
|
|
_inherit = "sale.order" |
|
|
_inherit = "sale.order" |
|
|
|
|
|
|
|
|
|
|
|
donation_amount=fields.Integer() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _cart_update(self, product_id=None, line_id=None, add_qty=0, set_qty=0,donation_amount=0, **kwargs): |
|
|
def _cart_update(self, product_id=None, line_id=None, add_qty=0, set_qty=0,donation_amount=0, **kwargs): |
|
|
""" Add or set product quantity, add_qty can be negative """ |
|
|
""" Add or set product quantity, add_qty can be negative """ |
|
|
self.ensure_one() |
|
|
self.ensure_one() |
|
|
|
|
|
if donation_amount>0: self.donation_amount=donation_amount |
|
|
product_context = dict(self.env.context) |
|
|
product_context = dict(self.env.context) |
|
|
product_context.setdefault('lang', self.sudo().partner_id.lang) |
|
|
product_context.setdefault('lang', self.sudo().partner_id.lang) |
|
|
SaleOrderLineSudo = self.env['sale.order.line'].sudo().with_context(product_context) |
|
|
SaleOrderLineSudo = self.env['sale.order.line'].sudo().with_context(product_context) |
|
@ -94,10 +96,11 @@ class SaleOrder(models.Model): |
|
|
'custom_value': custom_value['custom_value'] |
|
|
'custom_value': custom_value['custom_value'] |
|
|
}) for custom_value in custom_values] |
|
|
}) for custom_value in custom_values] |
|
|
|
|
|
|
|
|
if donation_amount>0: |
|
|
|
|
|
|
|
|
if self.donation_amount: |
|
|
|
|
|
|
|
|
values['product_uom_qty']=1 |
|
|
values['product_uom_qty']=1 |
|
|
values['price_unit']=int(donation_amount) |
|
|
|
|
|
values['price_total']=int(donation_amount) |
|
|
|
|
|
|
|
|
values['price_unit']=self.donation_amount |
|
|
|
|
|
values['price_total']=self.donation_amount |
|
|
|
|
|
|
|
|
# create the line |
|
|
# create the line |
|
|
order_line = SaleOrderLineSudo.create(values) |
|
|
order_line = SaleOrderLineSudo.create(values) |
|
@ -144,10 +147,11 @@ class SaleOrder(models.Model): |
|
|
order_line.tax_id, |
|
|
order_line.tax_id, |
|
|
self.company_id |
|
|
self.company_id |
|
|
) |
|
|
) |
|
|
if donation_amount>0: |
|
|
|
|
|
|
|
|
if self.donation_amount: |
|
|
|
|
|
|
|
|
values['product_uom_qty']=1 |
|
|
values['product_uom_qty']=1 |
|
|
values['price_unit']=int(donation_amount) |
|
|
|
|
|
values['price_total']=int(donation_amount) |
|
|
|
|
|
|
|
|
values['price_unit']=self.donation_amount |
|
|
|
|
|
values['price_total']=self.donation_amount |
|
|
order_line.write(values) |
|
|
order_line.write(values) |
|
|
|
|
|
|
|
|
# link a product to the sales order |
|
|
# link a product to the sales order |
|
|