filtrage du statut de facturation et fonction de search sur le champs calculé

This commit is contained in:
eloyoussef 2018-03-17 16:23:39 +01:00
parent 4aea2c069f
commit 5caa210dcc
3 changed files with 57 additions and 19 deletions

View File

@ -28,7 +28,44 @@ class GolemResourceReservation(models.Model):
_inherit = 'golem.resource.reservation'
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
@ -38,7 +75,7 @@ class GolemResourceReservation(models.Model):
partner_id = reservation.partner_id
product = reservation.resource_id.product_tmpl_id
amount = product.standard_price
quantity = reservation.hour_stop - reservation.hour_start
if product.id:
account_id = product.property_account_income_id.id
@ -64,7 +101,7 @@ class GolemResourceReservation(models.Model):
#'origin': ,
'account_id': account_id,
'price_unit': amount,
'quantity': 1.0,
'quantity': quantity,
'discount': 0.0,
'uom_id': product.uom_id.id,
'product_id': product.id,

View File

@ -48,20 +48,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</record>
<!-- Searches -->
<!--<record model="ir.ui.view" id="golem_resource_reservation_view_search">
<field name="name">GOLEM Resource Reservation Search</field>
<record model="ir.ui.view"
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="inherit_id" ref="golem_resource.golem_resource_reservation_view_search"/>
<field name="arch" type="xml">
<search>
<field name="date_start" />
<field name="date_stop" />
<field name="resource_id" />
<field name="user_id" />
<field name="partner_id" />
<field name="state" />
<filter name="to_validate" string="Reservation to Validate"
domain="[('state', '=', 'confirmed')]" />
<filter name="group_state" string="State"
<search position="inside">
<filter name="to_invoice" string="Reservation To Invoice"
domain="[('invoicing_state', '=', 'None')]" />
<filter name="invoice_draft" string="Invoice Draft"
domain="[('invoicing_state', '=', 'draft')]" />
<filter name="invoice_open" string="Invoice Open"
domain="[('invoicing_state', '=', 'open')]" />
<filter name="invoice_paid" string="Invoice Paid"
domain="[('invoicing_state', '=', 'paid')]" />
<!--<filter name="group_state" string="State"
context="{'group_by': 'state'}" />
<filter name="group_resource" string="Resource"
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"
context="{'group_by': 'date:week'}" />
<filter name="group_date_day" string="Day"
context="{'group_by': 'date:day'}" />
context="{'group_by': 'date:day'}" />-->
</search>
</field>
</record>-->
@ -84,7 +86,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
res_model="golem.reservation.invoice.wizard"
src_model="golem.resource.reservation"
view_mode="form"
view_id="golem_reservation_invoice_wizard_form"
multi="True"
target="new"
/>
@ -93,7 +94,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
res_model="golem.reservation.invoice.wizard"
src_model="golem.resource.reservation"
view_mode="form"
view_id="golem_reservation_invoice_wizard_form_editable"
multi="True"
target="new"
/>

View File

@ -57,12 +57,13 @@ class GolemReservationInvoiceWizard(models.TransientModel):
for reservation in self.reservation_ids:
product = reservation.resource_id.product_tmpl_id
amount = product.standard_price
quantity = reservation.hour_stop - reservation.hour_start
lines.append((0, 0, {
'name': reservation.resource_id.name,
#'origin': ,
'account_id': account_id,
'price_unit': amount,
'quantity': 1.0,
'quantity': quantity,
'discount': 0.0,
'uom_id': product.uom_id.id,
'product_id': product.id,