filtrage du statut de facturation et fonction de search sur le champs calculé
This commit is contained in:
parent
4aea2c069f
commit
5caa210dcc
@ -28,7 +28,44 @@ class GolemResourceReservation(models.Model):
|
|||||||
_inherit = 'golem.resource.reservation'
|
_inherit = 'golem.resource.reservation'
|
||||||
|
|
||||||
invoice_id = fields.Many2one('account.invoice')
|
invoice_id = fields.Many2one('account.invoice')
|
||||||
invoicing_state = fields.Selection(related="invoice_id.state", string="Invoicing Status", default="None")
|
invoicing_state = fields.Char(compute="_compute_invoicing_state",
|
||||||
|
search='_search_invoicing_state',
|
||||||
|
string="Invoicing Status",
|
||||||
|
default="None")
|
||||||
|
|
||||||
|
def _search_invoicing_state(self, operator, value):
|
||||||
|
if value == "None":
|
||||||
|
reservation = self.env['golem.resource.reservation'].search([('invoice_id', '=', False)])
|
||||||
|
return [('id', 'in', reservation.mapped('id'))]
|
||||||
|
else:
|
||||||
|
return [('invoice_id.state', operator, value)]
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
print '________________________________'
|
||||||
|
print("kelri")
|
||||||
|
|
||||||
|
if self.invoice_id:
|
||||||
|
invoicing_state = self.invoice_id.state
|
||||||
|
print "_____________________1"
|
||||||
|
print invoicing_state
|
||||||
|
return [('invoicing_state', operator, value)]
|
||||||
|
else:
|
||||||
|
invoicing_state = "None"
|
||||||
|
print '_____________________2'
|
||||||
|
print invoicing_state
|
||||||
|
return [('invoicing_state', operator, value)]
|
||||||
|
print invoicing_state
|
||||||
|
"""
|
||||||
|
@api.multi
|
||||||
|
@api.depends('invoice_id')
|
||||||
|
def _compute_invoicing_state(self):
|
||||||
|
""" Compute invoicing_state """
|
||||||
|
for reservation in self:
|
||||||
|
if reservation.invoice_id:
|
||||||
|
reservation.invoicing_state = reservation.invoice_id.state
|
||||||
|
else:
|
||||||
|
reservation.invoicing_state = "None"
|
||||||
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@ -38,7 +75,7 @@ class GolemResourceReservation(models.Model):
|
|||||||
partner_id = reservation.partner_id
|
partner_id = reservation.partner_id
|
||||||
product = reservation.resource_id.product_tmpl_id
|
product = reservation.resource_id.product_tmpl_id
|
||||||
amount = product.standard_price
|
amount = product.standard_price
|
||||||
|
quantity = reservation.hour_stop - reservation.hour_start
|
||||||
if product.id:
|
if product.id:
|
||||||
account_id = product.property_account_income_id.id
|
account_id = product.property_account_income_id.id
|
||||||
|
|
||||||
@ -64,7 +101,7 @@ class GolemResourceReservation(models.Model):
|
|||||||
#'origin': ,
|
#'origin': ,
|
||||||
'account_id': account_id,
|
'account_id': account_id,
|
||||||
'price_unit': amount,
|
'price_unit': amount,
|
||||||
'quantity': 1.0,
|
'quantity': quantity,
|
||||||
'discount': 0.0,
|
'discount': 0.0,
|
||||||
'uom_id': product.uom_id.id,
|
'uom_id': product.uom_id.id,
|
||||||
'product_id': product.id,
|
'product_id': product.id,
|
||||||
|
@ -48,20 +48,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Searches -->
|
<!-- Searches -->
|
||||||
<!--<record model="ir.ui.view" id="golem_resource_reservation_view_search">
|
<record model="ir.ui.view"
|
||||||
<field name="name">GOLEM Resource Reservation Search</field>
|
id="golem_resource_reservation_search_inherit_golem_resource_account">
|
||||||
|
<field name="name">GOLEM Resource Reservation Search Adaptations to invoicing</field>
|
||||||
<field name="model">golem.resource.reservation</field>
|
<field name="model">golem.resource.reservation</field>
|
||||||
|
<field name="inherit_id" ref="golem_resource.golem_resource_reservation_view_search"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search>
|
<search position="inside">
|
||||||
<field name="date_start" />
|
<filter name="to_invoice" string="Reservation To Invoice"
|
||||||
<field name="date_stop" />
|
domain="[('invoicing_state', '=', 'None')]" />
|
||||||
<field name="resource_id" />
|
<filter name="invoice_draft" string="Invoice Draft"
|
||||||
<field name="user_id" />
|
domain="[('invoicing_state', '=', 'draft')]" />
|
||||||
<field name="partner_id" />
|
<filter name="invoice_open" string="Invoice Open"
|
||||||
<field name="state" />
|
domain="[('invoicing_state', '=', 'open')]" />
|
||||||
<filter name="to_validate" string="Reservation to Validate"
|
<filter name="invoice_paid" string="Invoice Paid"
|
||||||
domain="[('state', '=', 'confirmed')]" />
|
domain="[('invoicing_state', '=', 'paid')]" />
|
||||||
<filter name="group_state" string="State"
|
<!--<filter name="group_state" string="State"
|
||||||
context="{'group_by': 'state'}" />
|
context="{'group_by': 'state'}" />
|
||||||
<filter name="group_resource" string="Resource"
|
<filter name="group_resource" string="Resource"
|
||||||
context="{'group_by': 'resource_id'}" />
|
context="{'group_by': 'resource_id'}" />
|
||||||
@ -74,7 +76,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<filter name="group_date_week" string="Week"
|
<filter name="group_date_week" string="Week"
|
||||||
context="{'group_by': 'date:week'}" />
|
context="{'group_by': 'date:week'}" />
|
||||||
<filter name="group_date_day" string="Day"
|
<filter name="group_date_day" string="Day"
|
||||||
context="{'group_by': 'date:day'}" />
|
context="{'group_by': 'date:day'}" />-->
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
</record>-->
|
</record>-->
|
||||||
@ -84,7 +86,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
res_model="golem.reservation.invoice.wizard"
|
res_model="golem.reservation.invoice.wizard"
|
||||||
src_model="golem.resource.reservation"
|
src_model="golem.resource.reservation"
|
||||||
view_mode="form"
|
view_mode="form"
|
||||||
view_id="golem_reservation_invoice_wizard_form"
|
|
||||||
multi="True"
|
multi="True"
|
||||||
target="new"
|
target="new"
|
||||||
/>
|
/>
|
||||||
@ -93,7 +94,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
res_model="golem.reservation.invoice.wizard"
|
res_model="golem.reservation.invoice.wizard"
|
||||||
src_model="golem.resource.reservation"
|
src_model="golem.resource.reservation"
|
||||||
view_mode="form"
|
view_mode="form"
|
||||||
view_id="golem_reservation_invoice_wizard_form_editable"
|
|
||||||
multi="True"
|
multi="True"
|
||||||
target="new"
|
target="new"
|
||||||
/>
|
/>
|
||||||
|
@ -57,12 +57,13 @@ class GolemReservationInvoiceWizard(models.TransientModel):
|
|||||||
for reservation in self.reservation_ids:
|
for reservation in self.reservation_ids:
|
||||||
product = reservation.resource_id.product_tmpl_id
|
product = reservation.resource_id.product_tmpl_id
|
||||||
amount = product.standard_price
|
amount = product.standard_price
|
||||||
|
quantity = reservation.hour_stop - reservation.hour_start
|
||||||
lines.append((0, 0, {
|
lines.append((0, 0, {
|
||||||
'name': reservation.resource_id.name,
|
'name': reservation.resource_id.name,
|
||||||
#'origin': ,
|
#'origin': ,
|
||||||
'account_id': account_id,
|
'account_id': account_id,
|
||||||
'price_unit': amount,
|
'price_unit': amount,
|
||||||
'quantity': 1.0,
|
'quantity': quantity,
|
||||||
'discount': 0.0,
|
'discount': 0.0,
|
||||||
'uom_id': product.uom_id.id,
|
'uom_id': product.uom_id.id,
|
||||||
'product_id': product.id,
|
'product_id': product.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user