mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: invoice line name automatic control
This commit is contained in:
@@ -32,11 +32,11 @@ class AccountMoveLine(models.Model):
|
||||
check_pms_properties=True,
|
||||
)
|
||||
name_changed_by_user = fields.Boolean(
|
||||
string="Custom label",
|
||||
readonly=False,
|
||||
default=False,
|
||||
store=True,
|
||||
compute="_compute_name_changed_by_user",
|
||||
string="Name set manually",
|
||||
help="""Techinal field to know if the name was set manually by the user
|
||||
or by the system. If the name was set manually, the system will not
|
||||
change it when the qty days are changed""",
|
||||
default=True,
|
||||
)
|
||||
pms_property_id = fields.Many2one(
|
||||
name="Property",
|
||||
@@ -60,24 +60,16 @@ class AccountMoveLine(models.Model):
|
||||
@api.depends("quantity")
|
||||
def _compute_name(self):
|
||||
for record in self:
|
||||
record.name = self.env["folio.sale.line"].generate_folio_sale_name(
|
||||
record.folio_line_ids.reservation_id,
|
||||
record.product_id,
|
||||
record.folio_line_ids.service_id,
|
||||
record.folio_line_ids.reservation_line_ids,
|
||||
record.folio_line_ids.service_line_ids,
|
||||
qty=record.quantity,
|
||||
)
|
||||
# TODO: check why this code doesn't work
|
||||
# if not record.name_changed_by_user:
|
||||
# record.with_context(auto_name=True).name = self
|
||||
# .env["folio.sale.line"].generate_folio_sale_name(
|
||||
# record.folio_line_ids.service_id,
|
||||
# record.folio_line_ids.reservation_line_ids,
|
||||
# record.product_id,
|
||||
# qty=record.quantity)
|
||||
# record.with_context(auto_name=True)
|
||||
# ._compute_name_changed_by_user()
|
||||
if record.folio_line_ids and not record.name_changed_by_user:
|
||||
record.name_changed_by_user = False
|
||||
record.name = self.env["folio.sale.line"].generate_folio_sale_name(
|
||||
record.folio_line_ids.reservation_id,
|
||||
record.product_id,
|
||||
record.folio_line_ids.service_id,
|
||||
record.folio_line_ids.reservation_line_ids,
|
||||
record.folio_line_ids.service_line_ids,
|
||||
qty=record.quantity,
|
||||
)
|
||||
|
||||
@api.depends("move_id")
|
||||
def _compute_pms_property_id(self):
|
||||
@@ -87,15 +79,6 @@ class AccountMoveLine(models.Model):
|
||||
elif not rec.pms_property_id:
|
||||
rec.pms_property_id = False
|
||||
|
||||
@api.depends("name")
|
||||
def _compute_name_changed_by_user(self):
|
||||
for record in self:
|
||||
# if not record._context.get("auto_name"):
|
||||
if not self._context.get("auto_name"):
|
||||
record.name_changed_by_user = True
|
||||
else:
|
||||
record.name_changed_by_user = False
|
||||
|
||||
@api.depends(
|
||||
"folio_line_ids",
|
||||
"payment_id",
|
||||
|
||||
@@ -939,6 +939,7 @@ class FolioSaleLine(models.Model):
|
||||
"analytic_account_id": self.folio_id.analytic_account_id.id,
|
||||
"analytic_tag_ids": [(6, 0, self.analytic_tag_ids.ids)],
|
||||
"folio_line_ids": [(6, 0, [self.id])],
|
||||
"name_changed_by_user": False,
|
||||
}
|
||||
if optional_values:
|
||||
res.update(optional_values)
|
||||
|
||||
@@ -1793,7 +1793,7 @@ class PmsFolio(models.Model):
|
||||
move = (
|
||||
self.env["account.move"]
|
||||
.sudo()
|
||||
.with_context(default_move_type="out_invoice", auto_name=True)
|
||||
.with_context(default_move_type="out_invoice")
|
||||
.create(invoice_vals)
|
||||
)
|
||||
moves += move
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
expr="//field[@name='invoice_line_ids']/tree/field[@name='quantity']"
|
||||
position="before"
|
||||
>
|
||||
<field name="name_changed_by_user" invisible="1" />
|
||||
<field name="name_changed_by_user" invisible="0" />
|
||||
<field
|
||||
name="pms_property_id"
|
||||
attrs="{'column_invisible':[('parent.pms_property_id','!=',False)]}"
|
||||
|
||||
Reference in New Issue
Block a user