Hello everyone,
I have a doubt, or rather a problem to solve....
I have created a button with the following conditions within the model stock.picking = makes the connection between the views of Receipts and Subcontrating Deliveries, this button appears a colour, according to the state of the order, and I need to add one more condition, that if the order has a transfer in receipts associated with subcontrating then, this button should appear, if not the button should be invisible.
It happens, that I need to create a field related to the name and the picking_type_id, I did that creation, but I think it's not well done, because in the view it's not working either, can someone help me and give me a clarification?
Below is my code and my xml.
Thanks in advance! :)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
you can try this way:
Define a new computed field in the stock.picking model that checks for the associated transfer in receipts and subcontrating. This field will determine the visibility of the button.
from odoo import models, fields, api
class StockPicking(models.Model):
_inherit = 'stock.picking'
is_transfer_receipt = fields.Boolean(compute='_compute_is_transfer_receipt', store=True)
@api.depends( 'picking_type_id')
def _compute_is_transfer_receipt(self):
for picking in self:
is_transfer_receipt = False
if picking.name and picking.picking_type_id.code == 'receipt':
transfer_receipts = self.env['stock.picking'].search([
('origin', '=', picking.name),
('picking_type_id.code', '=', 'subcontrating'),
])
if transfer_receipts:
is_transfer_receipt = True
picking.is_transfer_receipt = is_transfer_receipt
Make sure to replace 'your_button_field_name' with the actual field name you have defined for your button.
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
1
jul. 23
|
2354 | ||
Name inside the button
Opgelost
|
|
1
jul. 23
|
1712 | |
color for button based on state
Opgelost
|
|
1
jun. 23
|
2901 | |
|
2
aug. 23
|
2041 | ||
|
1
jun. 23
|
2221 |