Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] account_asset_management_stock_lot #2022

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from

Conversation

florian-dacosta
Copy link
Contributor

The goal here is to link a serial number with an asset in case you have some assets that you also manage in stock.

It is the case for instance (in France at least) when you rent some product instead of selling it, you can choose to create an asset.
This module does not do much right now, it is more about to have the right data model to implement more stuff, but it allow at least to filter your asset by serial number.

Copy link

@GuillemCForgeFlow GuillemCForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very interesting module 💯

@@ -100,7 +100,7 @@
<field name="date_remove" />
</group>
</group>
<group string="Other Information">
<group string="Other Information" name="general_info">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would separate this change into a different commit, to have one per module.


{
"name": "Assets Management Stock Lot",
"version": "16.0.1.2.5",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"version": "16.0.1.2.5",
"version": "16.0.1.0.0",

0.0 in the first version

<field name="arch" type="xml">
<xpath expr="//group[@name='general_info']" position="inside">
<group>
<field name="product_id" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<field name="product_id" />
<field name="product_id" attrs="{'invisible': [('stock_lot_id', '=', False)]}" />

WDYT about hiding the product when there is still no lot assigned?

</xpath>
</field>
</record>
</odoo>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another possible improvement would be to add the corresponding tree and search views

Copy link

@AndreuOForgeFlow AndreuOForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review 👍 . Pending changes to be approved

Copy link
Contributor

@AaronHForgeFlow AaronHForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I would let the user to pick the product first and then show the possible lots filtered, if you have many lots with the same number for different products it would be hard to choose one.

It would also be nice another glue module with the account_move_line_product so the product is set in the journal item and it is transferred to the asset. But I guess that is for another PR.

Thank you.

@AndreuOForgeFlow
Copy link

@florian-dacosta, We're interested to migrate this module to 17.0 once this is approved! I created the migration PR here in draft: #2024. I already added the changes that you're being suggested in this commit: ccd2b17 👍 .

@florian-dacosta
Copy link
Contributor Author

Thanks for the remarks,

LGTM, I would let the user to pick the product first and then show the possible lots filtered, if you have many lots with the same number for different products it would be hard to choose one.

That is a good question. The problem is I am not sure we want to have an asset linked to a product but no lot ?
I mean it would be quite strange to link an asset to a product without the possibility to know which product it is really in your stock right ?
I mean, there is already the issue if the product is managed by lot and not serial number, but this case seems like a possible case (like you produce a batch of X products which have the same lot and you create an asset for the whole lot).

Would the following would be a good idea for you :

  • Leave product AND lot readonly=False.
    if you fill the lot => it fill the product automatically (keep the _compute_product_id method)
  • If you fill the product, it make the lot as required in the view ? (+ should we add a constraints to always have a lot if we chose a product ?)
  • Add 2 computed not stored fields product_id_domain and lot_id_domain ?
  • Change the constraint _check_unique_asset to make sure we only have a asset per lot, no matter if we use serial number or lot ?

(Like I said, I feel like if we create an asset for a product we manage in stock, we need to identify exactly which are the product concerned. If the product is configured with lot, we should have 1 asset for the lot, but the lot could concerned a large quantity of product)
Does it make sense?

In my use case, it only concerns serial number for now, that is why I am not so sure about how to act with lot numbe (I don't have any use case for this yet).

We can also leave a lot more flexibility in the module, and make it ok to have any number of asset for a same lot number, or even allowing to link an asset to a product without lot? I am not sure
What do you think @AaronHForgeFlow @AndreuOForgeFlow @GuillemCForgeFlow

@GuillemCForgeFlow
Copy link

Hi @florian-dacosta, thanks for the reply and the input. 😄

IHMO, what you're describing makes sense to me, in a way that we should have the assets linked to only one lot/serial number, any of the two.

In that sense, we should have the user inputting the lot / serial number on the asset, to then have the product computed as you are describing, which should not be editable, it should just be displayed for information purposes.

I agree on the fact that you should have described the specific stock unit to the asset, but not a generic one. Then, according to said above, I would continue suggesting the same changes I have as pending.

@florian-dacosta
Copy link
Contributor Author

I have cherry-pick the commit with the pending suggestion.
I guess we could further improve or change depending of the comment of everyone.

compute="_compute_product_id",
store=True,
)
stock_lot_id = fields.Many2one("stock.lot", string="Lot")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
stock_lot_id = fields.Many2one("stock.lot", string="Lot")
stock_lot_id = fields.Many2one("stock.lot", string="Lot/Serial Number")

Maybe we could update the name to follow the Odoo way? https://github.com/odoo/odoo/blob/17.0/addons/stock/models/stock_move_line.py#L49
WDYT? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the Odoo way ? lot_id ?
I am not sure, because we are on an account model.
You would not name a many2one toward stock.move move_id on account.asset for instance, but you would name it stock_move_id, right ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @florian-dacosta, I was only mentioning the string attribute to be changed, see in the suggestion. For the field name, I guess they are all fine already 👍🏿

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll rename the string

Copy link

@GuillemCForgeFlow GuillemCForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, functional and code review 👍🏿
thanks for attending the suggestions 😄

@AaronHForgeFlow
Copy link
Contributor

That is a good question. The problem is I am not sure we want to have an asset linked to a product but no lot ?
I mean it would be quite strange to link an asset to a product without the possibility to know which product it is really in your stock right ?

Yes, totally agree. If the product is selected then the lot should be mandatory. In any case, for now, let's keep it as it is and then we can add more complexity later on if needed. My use case deals with serial numbers only.

Copy link
Contributor

@AaronHForgeFlow AaronHForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review

@florian-dacosta
Copy link
Contributor Author

@AaronHForgeFlow @GuillemCForgeFlow @AndreuOForgeFlow
Do you have some more complete use case in mind for this module ?

On my side, I am not sure on what should/could go in this module or in an other one, I guess it could help to check if your need are similar.

I need to :

  • Create an asset after a transfer (so, from a stock.move.line). + create an accounting entry to credit the asset account.
    At this time, if the stock is outside the company, it is not valuated anymore so I am fine
    At the contrary, if it is still inside the stock, I need to compensate its valuation (make an outgoing stock.valuation.layer)
    Because I don't want the product to be counted twice from an accounting point of view (in stock valuation + as an asset).
    So if a serial number is linked to an asset, I want to prevent it to be valuated, even if it comes back in the stock.

That is basically all I need.
Now, what triggers all of this (asset creation, and removing from stock.valuation.layer) I could differ a lot, and this would be the job of other modules.

More concrete use case using all this is the following.
My company manufacture a product and then sometimes sells it or sometimes rent it.
At manufacturing time, I don't know yet if the product will be sold or rented.
For sold products, there is no asset management, but for rented one, there is.
So, at the time one of the product goes to the rental location, then I would create the asset. This would be an rental module depending on this one for the trigger of the asset creation.

@AaronHForgeFlow
Copy link
Contributor

My use case is similar.

  • The company buys a machine with the intention of use it for rentals. It receives it and then send it to a special location. This location will be used as "Rental not valuated". The company will send the product to the customer from this location and it will get the products back in this location. This location is not valuated so as soon I move the product moves the Stock On Hand value decreases.
  • The idea is to create the asset as soon the product reaches that location, this asset is linked to the serial number so we can track what serial is being rented. Also it is linked to the account move resulting of the stock move to the "Rental not valuated" location.
  • If for some reason the serial comes back to stock the asset is cancelled.
  • If the serial is sold to the customer then the asset is marked as sold and it is delivered from that "Rental not valuated" location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants