mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Folio amount total compute
This commit is contained in:
@@ -122,8 +122,13 @@ class HotelFolio(models.Model):
|
||||
invoices_paid = fields.Monetary(compute='compute_amount',
|
||||
store=True, track_visibility='onchange',
|
||||
string="Payments")
|
||||
amount_total = fields.Float(string='Total', store=True, readonly=True,
|
||||
track_visibility='always')
|
||||
amount_untaxed = fields.Monetary(string='Untaxed Amount', store=True,
|
||||
readonly=True, compute='_amount_all',
|
||||
track_visibility='onchange')
|
||||
amount_tax = fields.Monetary(string='Taxes', store=True,
|
||||
readonly=True, compute='_amount_all')
|
||||
amount_total = fields.Monetary(string='Total', store=True, readonly=True,
|
||||
compute='_amount_all', track_visibility='always')
|
||||
|
||||
#Checkin Fields-----------------------------------------------------
|
||||
booking_pending = fields.Integer('Booking pending',
|
||||
@@ -145,12 +150,12 @@ class HotelFolio(models.Model):
|
||||
string='Invoice Status',
|
||||
compute='_compute_invoice_status',
|
||||
store=True, readonly=True, default='no')
|
||||
partner_invoice_id = fields.Many2one('res.partner',
|
||||
string='Invoice Address',
|
||||
readonly=True, required=True,
|
||||
states={'draft': [('readonly', False)],
|
||||
'sent': [('readonly', False)]},
|
||||
help="Invoice address for current sales order.")
|
||||
#~ partner_invoice_id = fields.Many2one('res.partner',
|
||||
#~ string='Invoice Address',
|
||||
#~ readonly=True, required=True,
|
||||
#~ states={'draft': [('readonly', False)],
|
||||
#~ 'sent': [('readonly', False)]},
|
||||
#~ help="Invoice address for current sales order.")
|
||||
|
||||
#WorkFlow Mail Fields-----------------------------------------------
|
||||
has_confirmed_reservations_to_send = fields.Boolean(
|
||||
@@ -174,7 +179,23 @@ class HotelFolio(models.Model):
|
||||
client_order_ref = fields.Char(string='Customer Reference', copy=False)
|
||||
note = fields.Text('Terms and conditions')
|
||||
sequence = fields.Integer(string='Sequence', default=10)
|
||||
|
||||
|
||||
@api.depends('room_lines.price_total','service_ids.price_total')
|
||||
def _amount_all(self):
|
||||
"""
|
||||
Compute the total amounts of the SO.
|
||||
"""
|
||||
for record in self:
|
||||
amount_untaxed = amount_tax = 0.0
|
||||
amount_untaxed = sum(record.room_lines.mapped('price_subtotal')) + \
|
||||
sum(record.service_ids.mapped('price_subtotal'))
|
||||
amount_tax = sum(record.room_lines.mapped('price_tax')) + \
|
||||
sum(record.service_ids.mapped('price_tax'))
|
||||
record.update({
|
||||
'amount_untaxed': record.pricelist_id.currency_id.round(amount_untaxed),
|
||||
'amount_tax': record.pricelist_id.currency_id.round(amount_tax),
|
||||
'amount_total': amount_untaxed + amount_tax,
|
||||
})
|
||||
|
||||
def _computed_rooms_char(self):
|
||||
for record in self:
|
||||
@@ -325,7 +346,7 @@ class HotelFolio(models.Model):
|
||||
if 'company_id' in vals:
|
||||
vals['name'] = self.env['ir.sequence'].with_context(
|
||||
force_company=vals['company_id']
|
||||
).next_by_code('sale.order') or _('New')
|
||||
).next_by_code('hotel.folio') or _('New')
|
||||
else:
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code('hotel.folio') or _('New')
|
||||
|
||||
|
||||
@@ -135,6 +135,7 @@
|
||||
<field name="cancelled_reason" attrs="{'invisible':[('state','not in',('cancel'))]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="pricelist_id" domain="[('type','=','sale')]" />
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
<field name="reservation_type" attrs="{'readonly':[('state','not in',('draft'))]}"/>
|
||||
<field name="channel_type" attrs="{'required':[('reservation_type','=','normal')]}"/>
|
||||
@@ -149,14 +150,12 @@
|
||||
</group>
|
||||
</group>
|
||||
<group invisible="1">
|
||||
<!-- <field name="pricelist_id" domain="[('type','=','sale')]" invisible="1"/> -->
|
||||
<!-- <field name="partner_shipping_id" invisible="1" domain="[('parent_id','=',partner_id)]" /> -->
|
||||
<!-- <field name="warehouse_id" string="Branch" invisible="1"/> -->
|
||||
<field name="invoice_ids" invisible="1"/>
|
||||
<field name="invoice_status" invisible="1" />
|
||||
<!-- <field name="hotel_invoice_id" states='progress,done,cancel'
|
||||
readonly="1" invisible="1" /> -->
|
||||
<!-- <field name="fix_price" invisible="1" /> -->
|
||||
</group>
|
||||
<notebook colspan="4" col="1">
|
||||
<page string="Lines">
|
||||
@@ -449,6 +448,15 @@
|
||||
<field name="channel_type" sttrs="{'invisible':[('channel_type', '!=', 'call')]"/>
|
||||
</tree>
|
||||
</field>
|
||||
<group colspan="2" class="oe_subtotal_footer oe_right">
|
||||
<field name="amount_untaxed" sum="Untaxed amount" widget='monetary' />
|
||||
<field name="amount_tax" widget='monetary' />
|
||||
<div class="oe_subtotal_footer_separator oe_inline">
|
||||
<label for="amount_total" />
|
||||
</div>
|
||||
<field name="amount_total" nolabel="1" sum="Total amount"
|
||||
widget='monetary' />
|
||||
</group>
|
||||
<div class="oe_clear" />
|
||||
<group>
|
||||
<field name="note" />
|
||||
|
||||
Reference in New Issue
Block a user