Skip to Content
Menú
This question has been flagged
870 Vistes

Hello,


I have an appointment button in POS session when click on it the POS order line is created with appointment details however when reload the page or change the qty, the price return back to the price related to the product and ignore the one I set during the creation.

const line_values = {
pos: this.pos,
order: this.pos.get_order(),
product: appointment.is_package ? this.pos.db.get_product_by_id(line.product_id) : this.pos.db.get_product_by_id(line.product_id[0]),
description: line.name,
price: appointment.is_package ? line.price : appointment.price,
price_manually_set: true,
resource_names: appointment.is_package ? await this._getResourceNames(line.resource_ids) : appointment.resource_id[1],
resource_ids: appointment.is_package ? await line.resource_ids : [appointment.resource_id[0]],
appointment_origin_id: clickedAppointment,
customer_note: line.description ? line.description : "",
};
const new_line = new Orderline({ env: this.env }, line_values); new_line.setQuantityFromService(qty);
new_line.set_unit_price(line_values.price);
this.pos.get_order().add_orderline(new_line);


class BusinessAppointment(models.Model):
_inherit = "business.appointment"



membership_id = fields.Many2one('customer.membership', string='Customer Membership', readonly= True, domain="[('partner_id', '=', partner_id),('status','=','active')]")
membership_package= fields.Many2one(related='membership_id.membership_package_id')
has_membership = fields.Boolean(string="Has Membership", compute='_compute_has_membership', store=False)
price = fields.Float(String="price", compute="get_price", store=False, )
service_price= fields.Float(String="price",)

@api.depends("service_id", "membership_id")
def get_price(self):
for rec in self:
rec.price = rec.service_id.product_id.lst_price
if rec.membership_id:
for consumed_service in rec.membership_id.consumed_service_ids:
if rec.service_id.product_id == consumed_service.product_id and consumed_service.remaining_times > 0:
rec.price = 0.0
break

how can Make the price not changed when reload the page or change the qty

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
d’oct. 24
1454
1
de jul. 25
568
3
de juny 25
2365
4
de jul. 25
1123
0
de nov. 24
1262